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...
Code:
#include <iostream>
void gameover(); // I declare the function
void level1():
int health = 100; // health is shown
int main()
{
if (health <=0) // call game over if health is equal or below zero
{
gameover();
}
level1();
return 0;
}
void level1()
{
code here
return;
}
void gameover() // gameover function
{
gameover function here
exit(0); // exit game command
return;
}
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?
I have been trying all I know and cannot get it to work,,, please help me!