示例#1
0
int click_menu(void) {
    switch (selected) {
        case 0:
            new_game();
        break;
        case 1:
            show_highscores(SCORE_NOMESSAGE);
        break;
        case 2:
            show_tutorial();
        break;
        case 3:
            show_credits();
        break;
        case 4:
            return 1;
        break;
    }
    return 0;
}
void initial_Window(void)
{
	//creates the window to show
	if(mode==0){
		iSetColor(0,255,100);
		iFilledRectangle(0,0,window_sizeX,window_sizeY);
		iShowBMP(0,0,"func_plot.bmp");
		iShowBMP(700,400,"cartesian.bmp");
		iShowBMP(700,300,"polar.bmp");
		
		iShowBMP(400,200,"help.bmp");
		iShowBMP(250,200,"credit.bmp");
	}
	
	if(mode==1) cartesian_draw();
	else if(mode==2) polar_draw();

	else if(mode==4) help_view();
	else if(mode==5) show_credits();


}
示例#3
0
文件: PL_ui.c 项目: drajvver/triplets
void show_menu()
{
    int who_first_start_game;
    int menu_choose;
    int control; // to verify if it is not a char!

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("1. Play : Player vs Computer (PvC)\n");
        printf("2. Play : Player vs Player (PvP)\n");
        printf("3. Game rules\n");
        printf("4. High scores\n");
        printf("5. Credits\n\n");
        printf("6. Exit Game.\n\n");
        printf("(Choose an option and press enter): ");



        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();


    }
    while (menu_choose<1 || menu_choose>6 || control == 0);


    switch(menu_choose)
    {

    case 1:
        G_current_game.game_mode=pvc;
        clearscr();
        printf("Triplets - Player vs Computer\n\n");
        printf("Enter your name: ");
        scanf("%s",G_players[0].name);
        strcpy(G_players[1].name, "CPU");// G_players[1] is cpu player
        choose_board();


        do
        {
            clearscr();
            printf("Triplets - %s vs %s\n\n", G_players[0].name, G_players[1].name);
            printf("Select who goes first:\n1. %s\n2. %s\n\n(Choose an option and press enter): ",G_players[0].name,G_players[1].name);
            control=scanf("%d",&who_first_start_game);
            clean_buffer_keyboard();

        }
        while (who_first_start_game<1 || who_first_start_game>2 || control==0);

        switch(who_first_start_game)
        {
        case 1:
            G_current_game.player_first= 1;
            break;
        case 2:
            G_current_game.player_first= 0;
            break;
        }

        clearscr();
        break;
    case 2:
        G_current_game.game_mode=pvp;
        clearscr();
        printf("Triplets - Player vs Player\n");
        printf("Enter the name of player 1: ");
        scanf("%s",G_players[0].name);
        printf("\nEnter the name of player 2: ");
        scanf("%s",G_players[1].name);
        choose_board();

        do
        {
            clearscr();
            printf("Triplets - %s vs %s\n\n", G_players[0].name, G_players[1].name);
            printf("Select who goes first:\n1. %s\n2. %s\n\n(Choose an option and press enter): ",G_players[0].name,G_players[1].name);
            control=scanf("%d",&who_first_start_game);
            clean_buffer_keyboard();
        }
        while (who_first_start_game<1 || who_first_start_game>2 || control==0);
        switch(who_first_start_game)
        {
        case 1:
            G_current_game.player_first= 1;
            break;
        case 2:
            G_current_game.player_first= 0;
            break;
        }
        clearscr();
        break;

    case 3:
        show_game_rules();
        show_menu();
        break;
    case 4:
        //show High scores//
        show_highscores();
        show_menu();
        break;
    case 5:
        show_credits();
        show_menu();
        break;
    case 6:
        exit(0);
        break;
    default:
        clearscr();
        show_menu();
        break;
    }
}
示例#4
0
 /**
 * This function shows the main menu
 *
 * @v info_s
 * @return	none
 * @date	2014-04-14
 * @author	PL Team
 **/
void show_menu()
{
    int menu_choose;
    int control; // to verify if it is not a char!
    char player1nameAux[MAX_PLAYERNAME_LENGTH]="";
    char player2nameAux[MAX_PLAYERNAME_LENGTH]="";

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("1. Play : Player vs Computer (PvC)\n");
        printf("2. Play : Player vs Player (PvP)\n");
        printf("3. Game rules\n");
        printf("4. High scores\n");
        printf("5. Replay game\n");
        printf("6. Credits\n\n");
        printf("7. Exit Game.\n\n");
        printf("(Choose an option and press enter): ");



        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();


    }
    while (menu_choose<1 || menu_choose>7 || control == 0);


    switch(menu_choose)
    {

    case 1:
        G_current_game.game_mode=pvc;
        G_current_game.pvp_mode = notpvp;
        show_difficulty();
        choose_interface();
        clearscr();
        printf("Triplets - Player vs Computer \n\n");
        do
        {
            printf("Enter your name: ");
            fgets(G_players[0].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[0].name);
            strcpy(player1nameAux,G_players[0].name);
            string_to_lower(player1nameAux);

            if (!strcmp(player1nameAux,"cpu"))
            {
                printf("Invalid name.\n");
            }
        }
        while (!strcmp(player1nameAux,"cpu"));
        strcpy(G_players[1].name, "CPU");// G_players[1] is cpu player
        choose_board();


        show_who_first();

        break;

    case 2:
        G_current_game.game_mode=pvp;
        G_current_game.cpu_mode = none;
        clearscr();
        printf("Triplets - Player vs Player\n");
        do
        {
            printf("Enter the name of player 1: ");
            fgets(G_players[0].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[0].name);
            strcpy(player1nameAux,G_players[0].name);
            string_to_lower(player1nameAux);

            if (!(strcmp(player1nameAux,"cpu")))
            {
                printf("Invalid name.\n");
            }
        }
        while (!(strcmp(player1nameAux,"cpu")));
        do
        {
            printf("\nEnter the name of player 2: ");
            fgets(G_players[1].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[1].name);
            strcpy(player2nameAux,G_players[1].name);
            string_to_lower(player2nameAux);

            if (!(strcmp(player2nameAux,"cpu")) || !(strcmp(player2nameAux,player1nameAux)))
            {
                printf("Invalid name.\n");
            }
        }
        while (!(strcmp(player2nameAux,"cpu")) || !(strcmp(player2nameAux,player1nameAux)));

        show_pvp_mode();
        if (G_current_game.pvp_mode == normal)
        {
            choose_interface();
        }
        else
        {
            G_current_game.interface_mode = console;
        }
        choose_board();
        show_who_first();

        break;

    case 3:
        show_game_rules();
        show_menu();
        break;
    case 4:
        //show High scores//
        show_highscores();
        show_menu();
        break;
    case 5:
        replay_menu(); // this is in PT_save_read_moves.c
        show_menu();
        break;
    case 6:
        show_credits();
        show_menu();
        break;
    case 7:
        exit(0);
        break;
    default:
        clearscr();
        show_menu();
        break;
    }
}
示例#5
0
文件: menu.cpp 项目: eldruin/OSEater
void menu ()
{
  unsigned char selected = 1;
  LCD_rectangle(0, 0, 132, 132, 1, BLACK);
  LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
  BLACK);
  LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
  LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
  LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
  while (1){
    unsigned int buttons = read_controls();
    if (buttons & BUTTON_CENTRAL){
      switch(selected){
      case 1:
        return;
      case 2:
        show_credits();
        selected = 1;
        LCD_rectangle(0, 0, 132, 132, 1, BLACK);
        LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
        break;
      case 3:
        show_help();
        selected = 1;
        LCD_rectangle(0, 0, 132, 132, 1, BLACK);
        LCD_print_string("/// OSEater \\\\\\", 4, 4, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Main Menu", 24, 28, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Play", 48, 48, BIG_FONT, RED, BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE, BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE, BLACK);
        break;
      }
    }
    if (buttons & BUTTON_DOWN){
      switch(selected){
      case 1:
        LCD_print_string("Play", 48, 48, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, RED,
                            BLACK);
        break;
      case 2:
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE,
                            BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, RED,
                            BLACK);
        break;
      default:
        selected--;
      }
      selected++;
    }
    else if (buttons & BUTTON_UP){
      switch(selected){
      case 2:
        LCD_print_string("Play", 48, 48, BIG_FONT, RED,
                            BLACK);
        LCD_print_string("Credits", 68, 36, BIG_FONT, WHITE,
                            BLACK);
        break;
      case 3:
        LCD_print_string("Credits", 68, 36, BIG_FONT, RED,
                            BLACK);
        LCD_print_string("Help", 88, 48, BIG_FONT, WHITE,
                            BLACK);
        break;
      default:
        selected++;
      }
      selected--;
    }
    delay(300000);
  }
}