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 / how do i move a sprite?

Author
Message
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 3rd Jun 2004 13:14
i'm making a simple test game where a flat stick shoots a bullet when the left mousebuttons is pressed. but i dont know how to move the bullet.. this is what i have so far:

if mouseclick()=1
sprite 2,mousex()+21,398,2
Move Sprite 2, 2.0
endif

The bullet is drawed on the screen. but it doesnt move
what do i do?
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 3rd Jun 2004 13:22
OK. I played around a bit with it for a while. now i have this:
Do
sprite 1,mousex(),400,1

if mouseclick()=1
x=mousex()
y=398
do
sprite 1,mousex(),400,1
sprite 2,x+21,y,2
y=y-2
if y=2 then exit
loop
endif
Loop

but there is a slight interuption in the bat movement (the bat is sprite 1) when the bullet is fired. how do i avoid this?
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 3rd Jun 2004 14:08
Hi,

I think you need to do something more along these lines... pseudo...

Do

Place your player sprite etc.

if mouseclick()=1 and firing=0 then firing=1

if firing=1 :`this sets the start point of the bullet
bul_x=mousex()
bul_y=398
firing=2
endif

if firing=2 :`this moves the bullet
move bullet
if bullet reaches destination, set firing to zero, e.g. firing=0,
allowing another shot to be taken.
endif

Loop

The idea is that firing has 3 states, 0=ready to fire, 1=init the start point of the bullet, and 2=bullet is firing.

Hope it helps,
Cheers.
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 3rd Jun 2004 15:03 Edited at: 3rd Jun 2004 15:04
thanks ...
now another question ..
i've made a background image for the game..
but there is an anoying blue screen that i cant get rid of
how do i get rid of that?
Bretticvs
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 3rd Jun 2004 18:58

that should turn the background to black, but you have to set your sprite to transparent i think otherwise it leaves a trail (dont quote me on this though)

C programmers dont die they just slip into the Void()

Login to post a reply

Server time is: 2024-09-22 11:22:38
Your offset time is: 2024-09-22 11:22:38