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 / How can I limit the shots that you can Fire in a 2D shoot em up?

Author
Message
Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 4th Aug 2003 18:31
Hi,
I am writing a small shoot em up game and I want my ship (its only a little box right now ) to be able to make 3 shots, then after getting a bonus 5 shots and so on. I tried it out a few times, but it doesn't work so good.

I coded it so, that the ship can fire 10 shots (after that, the user has to wait until all 10 bullets are destroyed). I will add the bonus system later, when the game does work I can fire 3 shots and then it gets buggy.

I hope someone can help me. My sourcecode is under the "source" tab.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 4th Aug 2003 18:37 Edited at: 4th Aug 2003 18:44
I think your problem is that you treat each bullet with its own little bit of code, for example:



In order to effectively limit your bullets you need a small chunk which repeats the same code over and over again for every bullet, without repeatedly typing out code code:



The limit the number of bullets, use some code like this



Now connecting the two examples you would get something like this:


Hope it helps.

You are the th person to view this signature.
GRAVITY: I fought the law but the law won
Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 4th Aug 2003 19:10
Thnx for the help, but I think I got it wrong. Here is my new code (I didn't used the bonus yet, I will ad it later). It fires 1 bullet and then a huge pack of bullets and after that, I can't fire anymore.
The game runs without any media, maybe you could try it and see for yourself, it is difficult to describe it with words (and my english is bad, too )
Vespar
22
Years of Service
User Offline
Joined: 17th Jul 2003
Location: USA
Posted: 5th Aug 2003 00:32
Insert this line whats happening is when you hit the space bar its using all ten in the 1 second you press the space bar.



Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 5th Aug 2003 02:11
Thnx, now it works!
I still got a few problems there, but I will try solving them on my own before I ask here

Thnx for your help, David89 and Vespar.
Vespar
22
Years of Service
User Offline
Joined: 17th Jul 2003
Location: USA
Posted: 5th Aug 2003 04:15
Glad to help just tell us what the problems are but by all means try to fix them yourself. Its a good way to learn.
Ves

Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 5th Aug 2003 06:03
I fixed the other problems I had and here is my code so far (under the source tab). I made a reload time, unusual for a shoot em up, but this gives me much more space for power ups
Next thing to do, will be the collision detection with the enemies and the enemie movings.

But there is a question I'd like to ask. What is the best system for displaying the 2D Backround? It shall scroll downwards. Do I have to make a huge 20000 x 768 Pixel Image as a sprite and move it down, or do I have to make 20 1024 x 768 Pixel images and glue them ingame together, or are tile engines used for such games?
Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 5th Aug 2003 16:41
Another day, another problem. Collision detection isn't working how it should. I used the "sprite collision(a,b)" command to check the collision between the laser and the enemy. This does work without problems. Then I destroy the sprite of the enemy and I put a new sprite at the location of the destroyed sprite. This is my power up. Then, the power up is moving downwards with the "move sprite a, b" command. I wrote this:



But It doesn't work. There is no collision between sprite 1 and sprite 100. I tried it with "sprite hit", too. But it's the same problem.
Vespar
22
Years of Service
User Offline
Joined: 17th Jul 2003
Location: USA
Posted: 6th Aug 2003 02:30 Edited at: 6th Aug 2003 03:05
Here is the collision code you wanted it also drops a bonus and the collision works. The problem was you were pasteing sprite 1. I have a rem statment that shows the error. Hope this help, let me know if you need other help.

Ves



Gunloader
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Germany
Posted: 8th Aug 2003 00:55
Thnx, now it does work!
Only problem left is the background, I will try using a giant sized image, maybe the speed is not so bad

Login to post a reply

Server time is: 2026-07-06 10:32:44
Your offset time is: 2026-07-06 10:32:44