Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / sprite movement

Author
Message
Senior Coder
20
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Greenwood,Nova Scotia,Canada
Posted: 28th Jun 2005 10:49
Hi all

I have decided to try DBPro again, hence this post.

I have a sprite that moves left/right using the arrow keys, but it moves very jerky. If I increase the number added or subtracted from the player's position, the movement just gets worse.

Any ideas on how to make the movement smoother?

Thanks

It's better to try and fail, than to fail by not trying
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 29th Jun 2005 00:11 Edited at: 29th Jun 2005 00:12
Post the code in a code snippet box -

This

[code ]Code goes here[/code ] =


(without the spaces in the [])

Also in future please do not make 2 threads on the same thing, just post again in the same thread.

NanoBrain
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 29th Jun 2005 12:16 Edited at: 29th Jun 2005 12:21
Senior Coder,

Are you using integers(whole numbers) or real numbers(floating-point numbers) for the x and y values of the sprites? If integers, this may be where your problem lies. However, we do need to see your code for you to get a more useful response.


+NanoBrain+
Senior Coder
20
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Greenwood,Nova Scotia,Canada
Posted: 30th Jun 2005 02:15
I have tried posting the code I have so far, using the Code: block of the Post Forum Message, but with no luck.

So, here is the code, and I apologize for not using the Code Snippet style, as I haven't figured that out yet!

REM Project: Arcade Shooter
REM Created: 27/06/2005 12:06:18 PM
REM
REM ***** Main Source File *****
REM
REM Initial game variables
PlayerX=800
PlayerY=400
true=1
set display mode 1024,768,32
set image colorkey 255,255,255
load image "airplane.bmp",1
set sprite 1,1,1
while true
if leftkey()=1 then PlayerX=PlayerX-10
if rightkey()=1 then PlayerX=PlayerX+10
sprite 1,PlayerX,PlayerY,1
endwhile

It's better to try and fail, than to fail by not trying
Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 30th Jun 2005 02:34
Try this code using sync to refresh the screen



The happenings of tommorow are behind us now
Senior Coder
20
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Greenwood,Nova Scotia,Canada
Posted: 30th Jun 2005 03:38
Okay, thanks! I will try that. I had actually read about Sync On and tried to implement it. I must have missed a step I guess.

It's better to try and fail, than to fail by not trying
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 2nd Jul 2005 05:11 Edited at: 2nd Jul 2005 05:13
Robot's idea will make your game not jerky, however I think he misplaced the sync command by accident; it should be within the while loop.

Like so


Also Senior Coder to use a code snippet box on the forums press the code button (at the far right of the text line when writing a message), this will insert a starting code tag into the message editor. Next paste your code after the tag, then press the code button again which will insert an end code tag in the message editor. The code you pasted in (or wrote) will be in a code snippet box.

Senior Coder
20
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Greenwood,Nova Scotia,Canada
Posted: 2nd Jul 2005 06:34
I will certainly use the code snippet feature in the future.
I will also try that code suggestion as well. I am certainly excited about trying DBPro again and from the replies here, the support is certainly there!

Thanks

It's better to try and fail, than to fail by not trying
Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 3rd Jul 2005 02:38
You are right pizzaman. That was intended to be inside the while loop.

The happenings of tommorow are behind us now
Senior Coder
20
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Greenwood,Nova Scotia,Canada
Posted: 3rd Jul 2005 23:22
I tried the suggested code and the ship movement is still not smooth. Maybe my method is all wrong?

Thanks


It's better to try and fail, than to fail by not trying
Goatpuzzle
22
Years of Service
User Offline
Joined: 12th Jun 2003
Location:
Posted: 17th Jul 2005 05:24
The problem is probably how much you're moving the sprite. How big is the sprite iself? With every press of the X or Y key, you're moving it ten pixels, which is quite a jump. If you're moving it that much in order to get it moving at a speed you want, you might want to try increasing the value in SYNC RATE instead, then reduce the number of pixels you're moving the sprite with each press.

Login to post a reply

Server time is: 2026-06-12 13:03:41
Your offset time is: 2026-06-12 13:03:41