Why is only one monster appearing at a time?

Started by
11 comments, last by yewbie 12 years, 8 months ago
THANKY YOU GUYS SO MUCH!!! Theres more then one monster now! But the way i implemented shooting causes a problem. I tried to make it as simplistic as i could, so pretty much did this

if( monster is on the left side of the player and player is looking left )
{
if( player presses space )
{
zombie is hurt;
}
}


The problem is, now with multiple zombies ALL of them on my left get hurt if im looking left and press space. So, what is the usual approach to 2D gun games concerning shooting?
Advertisement

So, what is the usual approach to 2D gun games concerning shooting?


This usually entails some sort of array of bullets, to which you create new bullets as the player presses the space bar. Then you add logic to check for intersections from the monster array and the bullet array:


for each bullet in bullets
for each monster in monsters
if intersects( monster, bullet ) then
if monster.damage( amount ) < 0 then
remove monster from monsters
remove bullet from bullets

[quote name='yewbie' timestamp='1313168959' post='4848322']If you looking at per unit random value seeding I would do something like srand(Time(NULL) + MyVector.size() );

And what advantages does that have compared to calling srand(time(0)) in main?
[/quote]
None, but I figured there would be someone wanting to do this for some reason /shrug

This topic is closed to new replies.

Advertisement