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! / Character firing projectile

Author
Message
Riz
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 3rd May 2009 05:49
Hey guys im almost finished with my fighting game and im putting the final touches on it i was wondering if i wanted to have my character to fire an object how exactly would i go about doing that. In my code when the Ctrl key is pressed my character punches but what if instead of having him punch he fired something i know i would load the projectile image that i would have him fire but then how would i make it that when i press the Ctrl key the character takes on the fighting pose and fires the projectile and it moves across the screen and hits the other player hope this makes sense any help would be greatly appreciated.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 4th May 2009 04:33 Edited at: 4th May 2009 04:34
I would create an array for projectiles like this:



And then create some code in your main loop that moves and updates all the projectiles in the array, like this:



And finally some code that starts the projectile:



All code untested, but you should get the idea.



Login to post a reply

Server time is: 2024-05-01 16:44:19
Your offset time is: 2024-05-01 16:44:19