Thread: Game over ?

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005

    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...

    #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
    return 0;
    void level1()
    code here
    void gameover() // gameover function 
    gameover function here
    exit(0); // exit game command
    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!

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM