예제 #1
0
void check_win(){

        if (flags == 0){
            for(i = 0; i < rows; i++){
                for (j = 0; j < columns; j++){
                    //all flags have bombs
                    if (button_arr[i][j].flag == 1 && button_arr[i][j].value != -1) return;
                    //all bombs have flags
                    if (button_arr[i][j].flag != 1 && button_arr[i][j].value == -1) return;
                }
            }
        } else {
            for(i = 0; i < rows; i++){
            for (j = 0; j < columns; j++){
                //all the hidden ones are bombs
                if (button_arr[i][j].state == 0 && button_arr[i][j].value != -1) return;
            }
        }
        }
      
        cli();
        _delay_ms(500);
        display_color(BLACK, GREEN);
        clear_screen();
        display_string_xy("CONGRATULATIONS! YOU WON! :D\n", 40, 100);
        display_string_xy("Press center to restart", 60, 130);
        display_string_xy("Hold < to return to menu", 56, 150);
        finish_game();
        sei();
}
예제 #2
0
int oneMovFinish(char board [SIZE][SIZE])
{
       int i,j;
       for(i=1;i<SIZE;i++){
	       for(j=1;j<SIZE;j++){
		       if(board[i][j]=EMPTY)
		       {
			       board[i][j]= PIECE;
			       if (finish_game(board,j,i)==1)
				       return 1;
			       else
				       board[i][j]= EMPTY;
		       }
	       }/*for j*/
       }/*for i*/
	       return 0;
}
예제 #3
0
파일: game.cpp 프로젝트: zemen/labyrinth
bool turn(Labyrinth &map) {
	take_objects_from_cell(map, map.player[map.current_player]);
	if (DEBUG)
		print_debug(map);
	user_message(map.player[map.current_player].name + ", it's your turn");
	string message = map.player[map.current_player].name + ", enter what you want (go, bomb, shoot, knife, suicide, stay, leave";
	if (SERVER)
		message += ")";
	else
		message += ", save)";
	user_message(message);
	
	if (SERVER)
		server.clear_user_messages(map.current_player);
	string s = read_user_command(map.current_player);
	
	if (s == "leave")
		return leave_game(map, map.player[map.current_player]);
	if (s == "suicide")
		return suicide(map, map.player[map.current_player]);
	if (s == "knife")
		return use_knife(map, map.player[map.current_player]);
	if (s == "bomb")
		return bomb(map, map.player[map.current_player]);
	if (s == "go")
		return go(map, map.player[map.current_player]);
	if (s == "shoot")
		return shoot(map, map.player[map.current_player]);
	if (s == "stay")
		return stay(map.player[map.current_player]);
	if (s == "save" && !SERVER) {
		save_game(map);
		return false;
	}
	if (s == "winthemall") {
		if (is_developer(map.player[map.current_player])) {
			user_message("Okay, master");
			finish_game(map);
			return true;
		}
	}
	
	user_message(map.player[map.current_player].name + ", you entered incorrect command! Try again, if you can!");
	return false;
}
예제 #4
0
파일: game.c 프로젝트: Ilych/life-simple
main()
{
	
	int k;
	init_world();
	
	init_curses();

	draw_vmap();

//	fskipc=0;

	do
	{ //Keyboard loop
		if(pause==0)
		{	

			evolv();

			//k=fskipc/fskip;

			if ((fskipc%fskip)==0)	
			{
				//fskipc=0;
				info_status();
				draw_vmap();
			}

			fskipc++;
			age++;

		}


		cho=getch();
	}
	while(kbd()); 


	finish_game();

	return(0);
}
예제 #5
0
파일: game.c 프로젝트: noox/Raketka
//posun hry o casovy tik
void update_game(float time, int k_up, int k_down, int k_right, int k_left, int k_fire) {
	//pozadi pro koncovy screen hry
	if (playerdead) { 
		move_stars(time);
		move_enemies(time);
		move_bullets(time);
		update_particles(time);
		move_bonuses(time);

		deathtimer-=time;
		if ((deathtimer<=0) && k_fire) { 
			//zacatek nove hry
			finish_game();
			init_game();
		}
	}

	else {
		handle_levels();
		
		//odecteni casu od casovacu bonusu
		shieldtimer-=time;
		canontimer-=time;

		reload+=time;

		//ovladani raketky (funkce z main.c)
		if (k_left) speedx-=time*1300;
		if (k_right) speedx+=time*1300;
		if (k_up) speedy+=time*1300;
		if (k_down) speedy-=time*1300;

		//strelba mozna jen po specifickem casovem intervalu 
		if (k_fire && ((canontimer>0)?(reload>(0.2/(plevel))):(reload>(0.5/(plevel*0.9))))) { 
			if (canontimer<=0)
				//strelba zavisla na power levelu
				add_bullet(posx, posy+50, 0, 200, plevel, 1, 1);
			else 
				//silenej gun po sebrani zeleneho bonusu
				add_bullet(posx, posy+50, 0.8*speedx+200*DFRAND*DFRAND*DFRAND, 300+speedy+20*DFRAND, 10*plevel, 1, 1); 
			reload=0;
		}
		
		//aplikace rychlosti raketky na pozici
		posx+=speedx*time;
		posy+=speedy*time;

		//aby raketka brzdila stejne pri ruznem frameratu
		speedx*=powf(0.02, time); //powf = exponenciela
		speedy*=powf(0.02, time);

		//okraje hraciho pole pro raketku
		if (posx<-225) {posx=-225; speedx=0;} 
		if (posx>225) {posx=225; speedx=0;}
		if (posy<-335) {posy=-335; speedy=0;}
		if (posy>-100) {posy=-100; speedy=0;}

		move_stars(time);
		move_enemies(time);
		move_bullets(time);
		update_particles(time);
		move_bonuses(time);
	}
}
예제 #6
0
void game (gamedata &g){

  SDL_Event event;
  quit = false;

  // Set first tick interval
  Uint32 next_time = SDL_GetTicks() + TICK_INTERVAL;

  while (!quit){
	  if(g.winner){
		finish_game(g);
		setup_game(g);
		GameState = STATE_INTRO;
		CurrentMenu = MenuMainIntro;
		SelectedItem = menuSwitchItem(CurrentMenu, 0);
		demo = true;
	  }
	 else if (g.winner == 0){

	    Uint8 *keys = SDL_GetKeyState(NULL);

	    if (SDL_PollEvent(&event) == 1){
	      switch (event.type){

	      case SDL_QUIT: {
		printf("Quit requested, quitting.\n");
		quit = true;
	      }
	      break;
	      }
	    }

	    if(GameState == STATE_INTRO || GameState == STATE_MENU)
	    {
		    menuInput(g);
	    }
	    else if(GameState == STATE_MENU_PLANE_SELECT)
	    {
		    menuPlanes(g);
	    }
	    else if(GameState == STATE_MENU_PLAYER_CONTROL_SELECT)
	    {
		    menuSelectPlayer(g);
	    }
	    else if(GameState == STATE_GAME)
	    {
		    if ((keys[SDLK_ESCAPE] == SDL_PRESSED) || (keys[51] == SDL_PRESSED)){
			keys[SDLK_ESCAPE] = SDL_RELEASED;
			GameState = STATE_MENU;
			CurrentMenu = MenuMain;
			SelectedItem = menuSwitchItem(CurrentMenu, 0);
		      //quit = true;
		    }
	    }

	    // Go through each plane individually
	    g.p.reset();
	    while (g.p.next()){

	      // Setup virtual joystick
	      int jx = 0;

	      int jy = 0;
	      bool jb = false;

	      if (g.p().state < 2){
		control(g, keys, jx, jy, jb);
		controlJoy(g, jx, jy, jb);
	      }
	      // Then move the plane
	      act(g, jx, jy, jb);
	      // Remove expunged planes
	      if (g.p().state == 4){
		g.drakms.fighter[g.p().id-7] = false;
		g.drakms.fightersout--;
		g.dp.reset();
		while(g.dp.next()){
		  if (g.dp().id == g.p().id) g.dp.kill();
		}
		g.p.kill();
	      }

	    }

	    // Then do everything else
	    all(g);
	    drawall(g);

	    // Delay for time remaining in TICK_INTERVAL
	    SDL_Delay(time_left(next_time));
	    next_time = SDL_GetTicks() + TICK_INTERVAL;

	  }
  }
}
예제 #7
0
void reveal_button(){

     button b;
     int e = get_selected_button(&b);
     if (e != 0){
        char disp[20];

        uint16_t x = b.posx;
        uint16_t y = b.posy;
        button_arr[x][y].state = 1;
        if (button_arr[x][y].flag == 1){
            if (flags < maxflags) {
                button_arr[x][y].flag = 0;
                ++flags;
                char disp[20];
                display_color(BLACK, def_button_col);
                sprintf(disp, "== %d ==", flags);         
                display_string_xy(disp, LCDHEIGHT/2 + 25, 13);
            }
        }

        if (b.value == -1){
            cli();
            button_col = RED;
            draw_button_background(x, y);
            display_color(BLACK,button_col);
            draw_button_content(x, y);
            draw_grid_lines(x,y);

            _delay_ms(1000);
            clear_screen();
            display_string_xy("GAME OVER :(\n", 110, 100);
            display_string_xy("Press center to restart", 60, 130);
            display_string_xy("Hold < to return to menu", 56, 150);
            finish_game();
            sei();
            return;
        } else {
            button_col = DIM_GRAY;
            draw_button_background(x, y);
            char n = b.value;
            if (n > 0){
                switch(n) {
                    case 1 :
                        display_color(BLUE,button_col);
                    break;
                    case 2 :
                        display_color(DARK_GREEN,button_col);
                    break;
                    case 3 :
                        display_color(RED, button_col);
                    break;
                    case 4:
                        display_color(PURPLE, button_col);
                    break;
                    default :
                        display_color(PURPLE,button_col);  
                }
                draw_button_content(x, y);
            }
            draw_grid_lines(x,y);
            check_neighbours(x,y);
            check_win();
        }
        
     }
     
}