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 / Space Invaders Help - Shooting?

Author
Message
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 22nd Oct 2005 16:54
Over the past couple of hours i have been working on a space invaders game. I've got the grid of enemies on screen (not moving, but you can customize how many there are etc). I have also got the player moving and shooting. My only problem is that when i shoot i cant move.

I'd really appreciate some help on this, even though its probably a really simple solution. I've attached all the appropriate files(8.6kb zipe file).

Cheers,

Mike

Attachments

Login to view attachments
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Oct 2005 17:45
I haven't looked at your code, I don't have to!

What you will be doing is calling the code to move your 'bullet' up the screen and it will be in a loop which doesn't exit until the bullet has hit something or gone off the top of the screen. While it's doing this, it can't update the position of the player.

What you need to do is use 'time-sharing' code which isn't in a locked loop. You use arrays to track multiple bullets and call the bullet procedure every time round the loop using variables to track their positions rather than use a loop.

Now do what you should have done in the first place and type 'shoot' into the search button and see how many times a question like this has been answered before!...

TDK_Man

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 22nd Oct 2005 17:52 Edited at: 22nd Oct 2005 18:35
Thanks for your help TDK. I did search for shoot but the majority of posts were for 3D FPS games. I have it working now though.

Thanks,

Mike

*** Formerly Code Monkey ***
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Oct 2005 02:28
Quote: "I have it working now though."


Good news!

If you are having problems creating multiple bullets, (or anyone else is struggling with shooting in a 2D game), I've added a 2D shooting tutorial to the tutorials section of my site (link at the bottom).

TDK_Man

Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 23rd Oct 2005 16:56
Thanks for the link TDK. You certainly have a lot of very useful tutorials on your site. My game is coming along really well now. I have the enemy movement programmed along with player shooting,scoring, and shields complete with damage. I have also been working on the music for my game which is coming along nicely too. Once I have finished my game I hope to create a tutorial guiding people through making a space invaders game. This will not only reinforce the ideas in my head, but allow me to help other beginners along their way.

Once again, thanks for your help,

Mike

*** Formerly Code Monkey ***
Blue Shadow
20
Years of Service
User Offline
Joined: 6th Feb 2004
Location:
Posted: 25th Oct 2005 20:59 Edited at: 25th Oct 2005 21:04
Hey again

Here is the latest version of my game.

[href]http://balder.prohosting.com/meddie/space invaders.zip[/href] ***Edit - For some reason this wont go to a clickable link. Sorry ***

I just wondered if someone could have a look at the code and see why the last alien images on the first and third rows are in the wrong places. I am using a for next loop to draw the aliens and setup the alien image numbers.

The appropriate functions are: draw_enemy_ships() and move_enemys().

I would also appreciate it if someone could offer some help as to why the aliens on the second row drift slowly to the left away from the others, even though they are controlled by the same code.

Thanks for your help,

Mike

PS Any general feedback on the game and music would be appreciated. Please, bare in mind however, that this game is still in its very early Alpha stage.

*** Formerly Code Monkey ***

Login to post a reply

Server time is: 2024-11-27 14:44:32
Your offset time is: 2024-11-27 14:44:32