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! / 2D Help

Author
Message
outSync
20
Years of Service
User Offline
Joined: 23rd Aug 2003
Location:
Posted: 24th Aug 2003 03:46
Okay, quick question(s).

I have it so when the player presses SPACE, the bullet will shoot out from his gun according to the fact if he is facing down, up, left or right.

This works, but once the bullet is fired, when the player faces up, the bullet goes up. Left, left, right, right, etc. etc. I just want the bullet to keep going forward. Any ideas?

Also, how do I make it so he can shoot more than one bullet in succesion?

Thanks in advance.

-VariableS-

2D Fan/Addict/Programmer
Watsisname
20
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Wales
Posted: 24th Aug 2003 04:43
Hi there,
I think I know what your problem is.

I believe you are using the same variable for the player and the bullets direction, in which case you need to use two separate variables for the bullets direction and the the players direction,

OR, there is some line in the main loop of your code like
bullet direction = players direction
The bullet direction should only equal the players direction when SPACE is pressed in some kind of 'if' statement
In pseudo code:
do (main loop)
if spacebar is pressed
shoot bullet
bullet direction = players direction
endif
Other stuff
loop (end of main loop)

For multiple bullets, you'll probably need multiple variables, or more practically an array that stores all bullet data (e.g. positions and directions). Might be a more efficient way, but that is the obvious one that comes to mind.

Sorry if that was a bit long winded. Hope it makes sense and you find the bug. If not, post your code!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Aug 2003 05:51
Have a look at this code I've put together for you. It should answer your questions ... I hope
outSync
20
Years of Service
User Offline
Joined: 23rd Aug 2003
Location:
Posted: 25th Aug 2003 01:24
I think I have it now, thanks to your advice. TY.

-VariableS-

2D Fan/Addict/Programmer

Login to post a reply

Server time is: 2024-03-02 15:32:51
Your offset time is: 2024-03-02 15:32:51