What is best for making Bullets?

Started by rancidrat, Mon 15/01/2007 10:45:24

Previous topic - Next topic

rancidrat

HI
I am working on a death match arena style game where you fight against enemys with a number of different guns and items from your inventory.
Everything works perfectly and im later gonna turn it into a whole adventure game.

I am currently using objects as the bullets/rockets, this works nicely with a
object.move(player.x, player.y+100, 15, noeblock) kinda thing
The problem is that this limits me to only 1 bullet at a time since the object gets reused everytime the player shoots.

My question:
Is there a way to do the same thing with maybe dynamic sprites or overlays?
I cant find any way to move the sprites across the screen once I draw them.
And..
If this is possible, how would I apply it to the
(AreThingsOverlapping(1004, cEnemy) line for collisions? (since it only works for characters and objects)
Thanks

Stupot

Bloody good question... I'm afraid I can't help you with the answer but I'd love to find out what other people say about it.

What if you had a limit, say twenty or fifty bullets and used the same sprite but saved them as individual objects.  Then once one bullet is fired, pressing fire will be told to shoot the next bullet instead of the same one again... if you see what i mean.  plus having a limit will add to the tension of the game.

rancidrat

Yeah thats a good idea Stupot, I did this:

int bulletnumber = 0;

if (bulletnumber >5)
{ buletnumber = 0;}


if ((IsKeyPressed(32) ==1) && (IsTimerExpired(1)==1))
{
object[bulletnumber].Move(mouse.x, mouse.y, 15, eNoBlock, eAnywhere);
SetTimer(1, 5);
bulletnumber++; }
}

so now the first 6 object in the room are your bullets, its cool, it looks like a machine gun firing hehe.
but I wish I did not have to waste objects like that since you only get 20 in a room :(

GarageGothic

Probably the easiest would be to draw the using RawDraw, but unless you also draw characters with RawDraw, the bullet would never be able to go in front of the characters. If the dimension of depth is important you may also consider using characters for the bullets, so you didn't have to waste room objects. Then you could even use the pixel-perfect collision detect module to detect hits.

Stupot

#4
Oh yeh i forgot you only had twenty objects per room.
I'm glad my idea worked for you, i wouldn't even be able to script it myself. hehe.

GG, your idea of useing characters for bullets is a good one.  See if you can get it working Rancidrat.

SMF spam blocked by CleanTalk