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.

Newcomers DBPro Corner / help with sprite movement and redraw problem

Author
Message
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 2nd Apr 2005 10:49
dbpro:
i need to be able to move a sprite using the arrow keys. i am building a small sidscroller. please do not give me the move sprite command seeing that it only does velocity. i tried using
if rightkey()=1 then sprite x(1)+2
and minus 2 for left. but they did not work. the other problem is when i use the sprite command and the gam loop when the sprite is moved evertime the game loops it goes back to the sprite psition.
ive included the source and a media. if you cant get the media please inprovise. still new to posting.
set display mode 800,600,32

load bitmap "game.bmp",0
load bitmap "penut.bmp",1

get image 1,462,1,510,173
get image 2,542,1,593,170
sync on

do
sprite 1,100,350,1
load bitmap "game.bmp",0
sync
wait 120
sprite 1,100,350,2
load bitmap "game.bmp",0
sync
wait 120
load bitmap "game.bmp",0
set current bitmap 0
load bitmap "game.bmp",0


if rightkey()=1 then move sprite 1,2
if leftkey()=1 then move sprite 1,-2



sync
loop

thankyou for your help.
you will need winzip to get the media

Attachments

Login to view attachments
Krad2004
19
Years of Service
User Offline
Joined: 8th Mar 2005
Location:
Posted: 2nd Apr 2005 17:23
first of all you need to set variables for your sprite x and y postitions like this:



and when u use the sprite command, put the bananaX and bananaY variables in the x and y positions, like this:



and for getting the sprite to move, try this:




hope this help
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Apr 2005 10:41
ty very much mate

Login to post a reply

Server time is: 2024-09-23 17:31:46
Your offset time is: 2024-09-23 17:31:46