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 needed with bullets

Author
Message
harmyboy
16
Years of Service
User Offline
Joined: 20th Jul 2008
Location:
Posted: 20th Jul 2008 14:34
(sorry for my bad english)
i need help with my bullets,
here is my code:



it's not finished yet but
if i shoot a bullet and move my sprite the y pos of the bullet is coming with the y pos of the sprite
somebody can help me out?
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 20th Jul 2008 17:59
Will you upload your media so that I can test your code? Or try to more clearly state your problem(I know your english is not good, but try)?
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 20th Jul 2008 18:19 Edited at: 20th Jul 2008 18:23
I changed your media to DBP generated media so I could run your code. NOW I know what you mean. The problem lies in this part of your code:



More specifically, it's right here:



You tell "bally" to always equal sprite 1's Y Position plus 10 because it's in the loop. It's getting run over and over again, so bally is being set equal to Sprite 1's Y Position over and over again. You only want this to happen once: when the player shoots the ball. All you really need to do is put this:

with your "if inkey$() = "m" and pf = 0" statement. So, that part should end up looking like this:



And your entire code should be like this:



Good luck


EDIT: I noticed that the ball stays at the right side of the screen when it's done moving, even though you set "ballx" equal to 30. This is because "pf" gets set to 0 so the sprite isn't updated until "pf" is equal to 1 again. To fix this you would need to do one of two things:
1) Draw the sprite again right after you set pf equal to 0.

OR

2) Cut and paste your SPRITE command to be after that IF statement.

If you wanted the ball to stay there then ignore this comment

harmyboy
16
Years of Service
User Offline
Joined: 20th Jul 2008
Location:
Posted: 20th Jul 2008 20:17
Thanks alot

i did a other way



with



i got another question

when player 2 is moving and someone press anotherkey then the walk keys from player 2
player 2 stops walking

Login to post a reply

Server time is: 2024-09-27 18:21:58
Your offset time is: 2024-09-27 18:21:58