Game over ?
Hi I am writing a very basic text adventure game, and i cannot get the game over function to work! When the health goes below zero, it goes into minuses, and ignores the function! Here is an example of what I mean, The game concists of 5000 lines of code so far, but I get no compile or link errors or warnings...
the above is very simular to what I have done in my game, so why is main not calling gameover when the health is nothing?
void gameover(); // I declare the function
int health = 100; // health is shown
if (health <=0) // call game over if health is equal or below zero
void gameover() // gameover function
gameover function here
exit(0); // exit game command
I have been trying all I know and cannot get it to work,,, please help me!
Just a guess - you are checking for health before level 1 even starts. At that point health = 100, and so gameover is never going to be called.