PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Making a top-down shooter

thrashmetal15 · 06 Dec 2005, 16:44 UTC
I'm working on a simple top-down shooter for PPC, and I'm having trouble working out how to make the ship fire many bullets in quick succession. I could make about 5 identical bullet sprites and just cycle through them as the fires a burst, but it seems that there should be a more efficient way. My code is a real mess right now, so it wouldn't really mean much to post it, lol. Any ideas, would be really appreciated.

Thanks,

thrashmetal15
Er, what do you mean? Just make a new sprite for every bullet, and once it's off-screen, delete it. There's no other way to do it.
You can use sponges idea, or you could use your idea of create and cloning a few bullets, then looping through them. I have done this before with success. The advantage to the later is you can allow players to only have, say, four bullets at a time very easily.
thrashmetal15 · 11 Dec 2005, 21:27 UTC
Ok, just checking. What I ended up doing was making a couple bullet sprites and just fire them in succession depending on the whereabouts of the other bullets. Thanks.
Conan · 12 Dec 2005, 06:23 UTC — bullets
what you want is a particle system. All this is is a large set of simple sprites all of which get processed each time throught the game loop. This allows for lots & lots of bullets flying all over the place. Give each one a lifetime which you decrement plus update the position. Only draw if active and on screen.
PPL has the particle you need! :) It's all there.
That's good to know. So it should be easy for this chap or anyone else to deal with lots of bullets firing off.
What is best in life?

"A man's greatest joy is to break his enemies, to drive them before him, to take from them all the things that have been theirs, to hear the weeping of those that cherished them, to take their horses between his knees and press in his arms the most desirable of their women."
-Genghis Kahn


Hail and well met Conan.

bmanske

P.S. Sorry I just couldn't resist...
Yes, Genghis gets it better than Conan in the movie. Conan says 'hear the lamentation of the women'. I would prefer the pressing in my arms more but maybe it was a rating thing :)
thrashmetal15 · 15 Dec 2005, 17:42 UTC
Never thought about using particles.......hmm...........
thrashmetal15 · 15 Dec 2005, 20:36 UTC
might be just what I needed if I could get the particle engine to work.

Code:

func AIProc(sprite$, msg$, wParam$, lParam$)
case(msg$)
WM_TIMER:
if(random(5)==1)
newparticle(1, enemyammo$, enemyl.x$, enemyl.y$,0,0,0,2,50,false,SpriteAlpha(enemyammo$),false, true)
end;

processparticles(0);
end;


correct me if I'm wrong but shouldn't this create a particle moving slowly down the screen with a chance of 1 out of 5? instead it creates about 5 particles at the beginning of the game, moving at an unbelievably high rate of speed downward, and then, nothing.[/code]
thrashmetal15 · 16 Dec 2005, 15:06 UTC
Ok, I'm not sure if this is a bug or not......, I stopped my background from scrolling, and my particles work now. Has anyone else had trouble with particles and a scrolling background?