コード例 #1
0
void CGetBlackOutDlg::OnPaint() 
{
	CDialog::OnPaint();
	CDC * dc = GetDC();
	drawall(dc);
	ReleaseDC(dc);
}
コード例 #2
0
ファイル: game.cpp プロジェクト: kokopalen/rs97_emulator
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;

	  }
  }
}