Skip to main content
GameDev.net gamedev.net
🔒 Locked

How ti fire multiple times

Started by Dhruv Jain Apr 21, 2013 at 5:07 AM 1 replies 1.5k views
Original Post
Dhruv Jain
Dhruv Jain

I am learning XNA and i just tried to make a game similar to galaga.I have made a ship to fire and i can fire a bullet.The problem is after i fire a bullet and user presses space[fire key] again my bullet disappears and new bullet appears at new location.

I am attaching the game file below.Please help me

L. Spiro
L. Spiro

That means you are using a single instance of a bullet instead of creating multiple bullets.

When bullets are fired, add them to a list of bullets held by an array/list/whatever C# calls them (functional equivalent of std::vector).

Update and render all bullets in that list each frame. Do remember to remove them when they die.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Dhruv Jain
Dhruv Jain

Thanks..Why the hell i did not think of it that way!!!I will try it and get back to you :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.