Beispiel #1
0
int main()
{
    resetgame();
    //prints the Main Menu
    mainmenu(cursor);

    char key;

    //Detect key UP and DOWN until ENTER is pressed
    do
    {
        key = getch();  //Get the input
        switch(key)
        {
            case 72 :
                mainmenu(--cursor); //Select upper menu
                break;
            case 80 :
                mainmenu(++cursor); //Select lower menu
                break;
        }
    } while(key!=13);

    //Launch a game or screen depending on the menu selected
    switch(cursor)
    {
        case 1 :
            singlegame();
            break;
        case 2 :
            multigame();
            break;
        case 3 :
            battlegame();
            break;
        case 4 :
            howtoplay();
            break;
        case 5 :
            credit();
            break;
        case 6 :
            exit(1);    //Exit game
    }
}
Beispiel #2
0
// Updates all nescessary sprites, images, buttons etc.
void update(void)
{
    static _Bool called = false;
    GDATAPTR game = get_game_data();
    update_background();
    if(game->gamestarted && game->paused)
    {
        paused(score, survival_time, lives);
    }
    else if(lives == 0)
    {
        gameover(score, survival_time);
    }
    else if(game->gamestarted)
    {
        if(!called)
        {
            //cpSpaceResizeStaticHash(get_global_cpSpace(), 700.0, 4*10);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 1, 2, collision_begin, NULL, NULL, NULL, NULL);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 2, collision_static_begin, NULL, NULL, NULL, NULL);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 1, collision_static_begin, NULL, NULL, NULL, NULL);
            called = false;
        }
        logic();
        update_clouds();
        cpSpaceStep(get_global_cpSpace(), 1.0f/60.0f);
        cpSpaceEachBody(get_global_cpSpace(), &update_sprites, NULL);
        update_ground();
        update_lives();
        add_element_to_render_queue(NULL, 0, 0, 0, RCOLOR(0, 0, 0, 255), update_score);
        add_element_to_render_queue(NULL, 290, 0, 0, RCOLOR(0, 0, 0, 255), update_survivaltime);
    }
    else if(game->options)
    {
        options();
    }
    else if(game->howtoplay)
    {
        howtoplay();
    }
    else if(game->highscores)
    {
        highscores();
    }
}