Making a simple 2d birds eye view zombie survival, I am woundering how to make a simple timer to use in my code in order to set a pace for the zombie spawns and also slow down movement. (I am assuming this would solve the problem, it very well might not.)
My code is pretty basic for moving as a the person its just
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
if (keys[SDLK_UP])
{
ManY -= 1;
}
if (keys[SDLK_DOWN])
{
ManY += 1;
}
if (keys[SDLK_RIGHT])
{
ManX += 1;
}
if (keys[SDLK_LEFT])
{
ManX -= 1;
}
if(keys[SDLK_SPACE])
{
shoot=true;
}
|
All that does is control the character.
Questions I need help with:
Q: How can I get 4 zombies to spawn in their individual corners at a set frequency (every 3 seconds)
A: ???
Q: At the moment my movement is way to fast with that code, even set at - or + 1 pixel, what can I do in order to slow down movement.
A: ???
Q: When space bar is pressed I can make a bullet spawn and move in a set direction. How can I check what direction the man is facing? Should I make four if statments like
if(shoot=true && left=true)
[
bullet draw sprite etc.
]
And in the movement when you press down an arrow key it sets left right up and down all to false and sets w.e key you pressed to true so when you press space it checks which one is true to determine the direction the bullet should go and just subtract + or - X pixels from it x or y depending on the direction they are facing, would that work as a soulution?
A: ??
Q: Lastly I have an idea of a way to get the zombies to chase the person just have them move at a set pace based on the net of their ManX-ZombieX and ManY-ZombieY.
A: ??
Thank you for reading this, sorry for all the novice questions.
Any help you guys can provide would be GREATLY appreciated