Exemplo n.º 1
0
/* The pointer has either entered or left the canvas */
gboolean cb_canvas_pointer(GtkWidget *widget, GdkEvent *event, gpointer data) {
	GuiInfo *gui;
	gui = (GuiInfo *) data;

	if(event->type == GDK_ENTER_NOTIFY && gui->game->state != STATE_STOPPED) {
		/*if(!gui->game->flags->keyboard_control && !gui->game->flags->pause_on_focus_loss) {
			cb_grab_focus(GTK_WIDGET(gui->canvas), NULL, NULL);
		}*/
		if(gui->game->flags->hide_pointer) {
			cb_hide_pointer(GTK_WIDGET(gui->canvas), NULL, NULL);
		}
		pause_game(gui->game, PAUSE_POINTER, 1);
	} else if(event->type == GDK_LEAVE_NOTIFY) {
		/*if(!gui->game->flags->keyboard_control && !gui->game->flags->pause_on_focus_loss) {
			cb_ungrab_focus(GTK_WIDGET(gui->canvas), NULL, NULL);
		}*/
		cb_show_pointer(GTK_WIDGET(gui->canvas), NULL, NULL);
		if(gui->game->flags->pause_on_pointer) {
			pause_game(gui->game, PAUSE_POINTER, 0);
		}
	
	}
	
	return TRUE;
}
Exemplo n.º 2
0
/* Just calls pause_game. Included for consistency */
void cb_pause_game(GtkWidget *widget, gpointer data) {
	GuiInfo *gui;
	gui = (GuiInfo *) data;

	if(gui->game->pause_state & PAUSE_MENU) {
		pause_game(gui->game, PAUSE_MENU, 1);
	} else {
		pause_game(gui->game, PAUSE_MENU, 0);
	}
}
Exemplo n.º 3
0
Arquivo: help.c Projeto: lollek/imoria
void wizard_help()
{
  /*{ Help for available wizard commands                            }*/

      clear_screen();
      prt("^A -  Remove Curse and Cure all maladies.",1,1);
      prt("^B -  Print random objects sample.",2,1);
      prt("^D -  Down/Up n levels.",3,1);
      prt("^E - *Change character.",4,1);
      prt("^F - *Delete monsters.",5,1); 
      prt("^G - *Allocate treasures.",6,1);
      prt("^H -  Wizard Help.",7,1);
      prt("^I -  Identify.",8,1);
      prt("^J - *Gain experience.",9,1);
      prt("^K - *Summon monster.",10,1);
      prt("^L -  Wizard light.",11,1);
      prt("^N -  Print monster dictionary.",12,1);
      prt("^O - *Summon monster by its name.",13,1);
      prt("^P -  Wizard password on/off.",14,1);
      prt(" s - *Statistics on item (in inventory screen).",15,1);
      prt("^T -  Teleport player.",16,1);
      prt("^U - *Roll up an item.",17,1);
      prt("^V -  Restore lost character.",18,1);
      prt("^W - *Create any object *CAN CAUSE FATAL ERROR*",19,1);
      prt("^X - *Edit high score file",20,1);
      pause_game(24);
      draw_cave();
}
bool save_game(
    void)
{
    pause_game();
    show_cursor();

    /* Translate the name, and display the dialog */
    FileSpecifier SaveFile;
    get_current_saved_game_name(SaveFile);
    char GameName[256];
    SaveFile.GetName(GameName);

    char Prompt[256];
    // Must allow the sound to play in the background
    bool success = SaveFile.WriteDialogAsync(
                       _typecode_savegame,
                       getcstr(Prompt, strPROMPTS, _save_game_prompt),
                       GameName);

    if (success)
        success = save_game_file(SaveFile);

    hide_cursor();
    resume_game();

    return success;
}
Exemplo n.º 5
0
Arquivo: pause.c Projeto: EVWeb/naev
/**
 * @brief Pauses the game and marks the pause as player-initiated.
 */
void pause_player (void)
{
   if (paused)
      return;

   pause_game();
   player_paused = 1;
}
Exemplo n.º 6
0
Arquivo: menu.c Projeto: naev/naev
/**
 * @brief Function to active the new game menu.
 *    @param str Unused.
 */
static void menu_main_tutorial( unsigned int wid, char* str )
{
   (void) str;
   (void) wid;
   window_destroy( wid );
   menu_Close(MENU_MAIN);
   pause_game();
   player_newTutorial();
}
Exemplo n.º 7
0
/* The application has gained or lost focus */
gboolean cb_main_focus_change(GtkWidget *widget, GdkEvent *event, gpointer data) {
	GuiInfo *gui;
	GdkEventFocus *fevent;
	
	gui =  (GuiInfo *) data;
	fevent = (GdkEventFocus *) event;

	if(fevent->in) {
		/* Gained focus */
		pause_game(gui->game, PAUSE_FOCUS, 1);
	} else {
		/* Lost Focus */
		if(gui->game->flags->pause_on_focus) {
			pause_game(gui->game, PAUSE_FOCUS, 0);
		}
	}

	return FALSE;
}
Exemplo n.º 8
0
/* Preferences dialog has been destroyed */
static void cb_pref_destroy(GtkWidget *widget, gpointer data) {
	GuiInfo *gui;
	gui = (GuiInfo *) data;

	dialog = NULL;

	destroy_flags(newflags);

	pause_game(gui->game, PAUSE_PREF, 1);
}
Exemplo n.º 9
0
Arquivo: menu.c Projeto: naev/naev
/**
 * @brief Closes the main menu.
 */
void menu_main_close (void)
{
   if (window_exists("Main Menu"))
      window_destroy( window_get("Main Menu") );
   else
      WARN( _("Main menu does not exist.") );

   menu_Close(MENU_MAIN);
   pause_game();
}
bool save_game(void)
{
	pause_game();
    bool success = create_quick_save();
    if (success)
        screen_printf("Game saved");
    else
        screen_printf("Save failed");
	resume_game();

	return success;
}
Exemplo n.º 11
0
Arquivo: menu.c Projeto: naev/naev
/**
 * @brief Function to active the new game menu.
 *    @param str Unused.
 */
static void menu_main_new( unsigned int wid, char* str )
{
   (void) str;
   (void) wid;

   /* Closes the main menu window. */
   window_destroy( wid );
   menu_Close(MENU_MAIN);
   pause_game();

   /* Start the new player. */
   player_new();
}
Exemplo n.º 12
0
// Shows the inventory
void
show_inventory(void)
{
  WINDOW * w_inv;
  COORDS co;
  int t_freeze;

  w_inv = create_win(0, 0, 0, 0, 1, CP_WHITEBLUE);
  co = get_geometry(w_inv);
  set_winstr(w_inv, (co.x - (int) strlen("INVENTORY")) / 2, 1, A_BOLD,
             CP_WHITEBLUE, "INVENTORY");

  t_freeze = pause_game();
  set_inputmode(IM_KEYPRESS);
  getch();
  rm_win(w_inv);
  resume_game(t_freeze);
}
Exemplo n.º 13
0
void pause_game() {
	/*
	** status = 0, game is running
	** status = 1, game is paused
	*/
	static uint8_t status = 0;
	char c = 0;

	if(status) {
		move_cursor(28, TITLEY);
		clear_to_end_of_line();
		show_instruction(PLAYING);
		render_board();
		foodTimerNum = execute_function_periodically(BLINKRATE, blink_food);
		ratsTimerNum = execute_function_periodically(RATSPEED, move_rats);
		status = 0;
	}
	else {
		show_instruction(PAUSE);
		cancel_software_timer(foodTimerNum);
		cancel_software_timer(ratsTimerNum);
		empty_display();
		status = 1;

		while(c != 'p' && c != 'P'){
			if(input_available())
				c = fgetc(stdin);

			if(c == 's' || c == 'S'){
				save_state();
				//move_cursor(0, TITLEY);
				//clear_to_end_of_line();
				move_cursor(28, TITLEY);
				printf_P(PSTR("State has been saved."));
				c = 0;
			}

		}
		pause_game();

	}
}
Exemplo n.º 14
0
void ud__kingly()
{
  /*{ Change the player into a King!			-RAK-	}*/
  /*	{ Change the character attributes...		}*/

  dun_level = 0;
  strcpy(died_from, "Ripe Old Age");

  if ( characters_sex() == MALE ) {
    strcpy(PM.title, "Magnificent");
    strcat(PM.tclass, " King");
  } else {
    strcpy(PM.title, "Beautiful");
    strcat(PM.tclass, " Queen");
  }

  PM.lev      +=  MAX_PLAYER_LEVEL;
  PM.account  +=  250000;
  PM.max_exp  +=  5000000;
  PM.exp       =  PM.max_exp;

  /*{ Let the player know that he did good...	}*/
  clear_from(1);
  dprint("                                  #",2);
  dprint("                                #####",3);
  dprint("                                  #",4);
  dprint("                            ,,,  $$$  ,,,",5);
  dprint("                        ,,=$   \"$$$$$\"   $=,,",6);
  dprint("                      ,$$        $$$        $$,",7);
  dprint("                      *>         <*>         <*",8);
  dprint("                      $$         $$$         $$",9);
  dprint("                      \"$$        $$$        $$\"",10);
  dprint("                       \"$$       $$$       $$\"",11);
  dprint("                        *#########*#########*",12);
  dprint("                        *#########*#########*",13);
  dprint("                          Veni, Vidi, Vici!",16);
  dprint("                     I came, I saw, I conquered!",17);
  dprint("                      All Hail the Mighty King!",18);
  flush();
  pause_game(24);
  
};
Exemplo n.º 15
0
void make_preferences_box(GuiInfo *gui) {
	GtkNotebook *window_notebook;
	
	/* Don't let the user run two preferences boxes at the same time */
	if(dialog) {
		gdk_window_show( dialog->window );
		gdk_window_raise( dialog->window);
		gtk_widget_grab_focus(GTK_WIDGET(dialog));
		return;
	}

	if(gui->game->flags->pause_on_pref) {
		pause_game(gui->game, PAUSE_PREF, 0);
	}

	newflags = copy_flags(gui->game->flags);

	init_preferences_box(gui, &window_notebook);
	init_game_page(gui, window_notebook); 
	init_control_page(gui, window_notebook);
	set_flags_changed(FALSE);

	gtk_widget_show_all(dialog);
}
Exemplo n.º 16
0
//Main program
int main() {
	
	/* Initialize SDL’s video system and check for errors */
	if (SDL_Init(SDL_INIT_VIDEO) != 0) {

		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		return 1;
	}
	
	/* Make sure SDL_Quit gets called when the program exits! */
	atexit(SDL_Quit);
	
	/*set window title*/
	SDL_WM_SetCaption("Essi Invaders", "P");
	
	/* Attempt to set a 800x600 8 bit color video mode */
	screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8, SDL_DOUBLEBUF );
	
	if (screen == NULL) {
		
		printf("Unable to set video mode: %s\n", SDL_GetError());
		return 1;
	}

	//load images
	load_image("titlescreen.bmp", &title_screen, magenta);
	load_image("cmap.bmp", &cmap, magenta);
	load_image("target1.bmp", &invaders_img[0], magenta);
	load_image("target2.bmp", &invaders_img[1], magenta);
	load_image("target3.bmp", &invaders_img[2], magenta);
	load_image("target4.bmp", &invaders_img[3], magenta);
	load_image("target5.bmp", &invaders_img[4], magenta);
	load_image("target6.bmp", &invaders_img[5], magenta);
	load_image("target7.bmp", &invaders_img[6], magenta);
	load_image("target8.bmp", &invaders_img[7], magenta);
	load_image("target9.bmp", &invaders_img[8], magenta);
	load_image("target10.bmp", &invaders_img[9], magenta);
	load_image("target11.bmp", &invaders_img[10], magenta);
	load_image("target12.bmp", &invaders_img[11], magenta);
	load_image("spaceship.bmp", &player_img, magenta);
	load_image("essi.bmp", &logo_img, magenta);
	load_image("saucer.bmp", &saucer_img, magenta);
	load_image("gameover.bmp", &game_over_img, magenta);
	load_image("damage.bmp", &damage_img, lime);
	load_image("damagetop.bmp", &damage_top_img, lime);

	Uint32 next_game_tick = SDL_GetTicks();
	int sleep = 0;
	Uint8 *keystate = 0;
	int quit = 0;
	SDL_Event event;

	init_score();
	init_bases();
	init_misil();
	init_invaders();
	init_player();
	init_saucer();
	init_bullets(bullets, P_BULLETS);
	init_bullets(enemy_bullets, E_BULLETS);
	state = menu;
	title_time = SDL_GetTicks();
		
	/* Animation */
	while (quit == 0) {
		
		/* Grab a snapshot of the keyboard. */
		keystate = SDL_GetKeyState(NULL);
		
		while (SDL_PollEvent(&event)) {

			switch(event.type) {
				
				case SDL_KEYDOWN:
					
					switch( event.key.keysym.sym ) {
					
						//exit out of game loop if escape is pressed
						case SDLK_ESCAPE:
							
							quit = 1;
						break;
						
						case SDLK_SPACE:	
						
							if (state == menu) {

								state = game;

							} else if (state == game){
								
								player_shoot();
								saucer_ai();
							
							} else if (state == game_over) {
							
								init_invaders();
								init_bases();
								init_score();
								init_player();
								state = game;
								match = -1;
							}
						break;
						
						default:
						break;
					}
				break;
				
				case SDL_KEYUP:
					switch( event.key.keysym.sym ) {
						
						case SDLK_UP:
							
							move_misil(up);
						break;
						
						case SDLK_DOWN:	
						
							move_misil(down);
						break;
						
						default:
						break;
					}
			}
		}
	
		draw_background();

		if (state == menu) {
			
			char s[] = "Press SPACEBAR to start";
			SDL_Rect src[60];
			
			int i;

			if (title_time + 2000 < SDL_GetTicks())  {
			
				src[0].x = (SCREEN_WIDTH/100)*30;		//Yellow Background of Space Invaders
				src[0].y = 40;
				src[0].w = 440;
				src[0].h = 230;
			
				SDL_FillRect(screen, &src[0], 248);
			
			} else {
			
				int y = 0;

				for (i = 0; i < 60; i++) {
				
					src[i].x = 0;
					src[i].y = y;
					src[i].w = SCREEN_WIDTH;
					src[i].h = 10;

					SDL_FillRect(screen, &src[i], 227);
				
					y += 10;							
				}
			
				for (i = 0; i < 60; i++) {

					SDL_FillRect(screen, &src[i], rand() % 255);

				}
			}
			
			draw_title_screen();	
			draw_string(s, (SCREEN_WIDTH / 2) - (strlen(s) * 10), 500);

		} else if (state == game) {

			//move player
			if (keystate[SDLK_LEFT]) {
				
				move_player(left);
			}

			if (keystate[SDLK_RIGHT]) {
				
				move_player(right);
			}
			
			draw_hud();
			draw_player();
			draw_bases();
			draw_invaders();
			draw_saucer();
			draw_serviceProjectMatch(match);
			draw_bullets(bullets, P_BULLETS);
			draw_bullets(enemy_bullets, E_BULLETS);
			enemy_hit_collision();
			player_hit_collision();
			enemy_base_collision();
			saucer_hit_collision();
			bullet_base_collision(enemy_bullets, E_BULLETS, 1);
			bullet_base_collision(bullets, P_BULLETS, 0);
			enemy_player_collision();
			move_invaders(invaders.speed);
			move_saucer();
			movenemy_bullets(bullets, P_BULLETS, -30);
			movenemy_bullets(enemy_bullets, E_BULLETS, 15);
			calculate_level();
			enemy_ai();
			game_over_ai();
			pause_game();
		
		} else if (state == game_over) {
			
			draw_hud();
			draw_player();
			draw_bases();
			draw_invaders();
			draw_saucer();
			draw_bullets(bullets, P_BULLETS);
			draw_bullets(enemy_bullets, E_BULLETS);
			draw_game_over();
		
		} else if (state == pause) {
			
			draw_hud();
			draw_player();
			draw_bases();
			draw_invaders();
			draw_saucer();
			draw_bullets(bullets, P_BULLETS);
			draw_bullets(enemy_bullets, E_BULLETS);
			pause_game();
		}

		/* Ask SDL to update the entire screen. */
		SDL_Flip(screen);

		next_game_tick += 1000 / 30;
		sleep = next_game_tick - SDL_GetTicks();
	
		if( sleep >= 0 ) {

            		SDL_Delay(sleep);
        	}
	}
	
	return 0;
}
Exemplo n.º 17
0
Arquivo: toolkit.c Projeto: Delll/naev
/**
 * @brief Creates a window.
 *
 *    @param name Name of the window to create.
 *    @param x X position of the window (-1 centers).
 *    @param y Y position of the window (-1 centers).
 *    @param w Width of the window (-1 fullscreen).
 *    @param h Height of the window (-1 fullscreen).
 *    @return Newly created window's ID.
 */
unsigned int window_create( const char* name,
      const int x, const int y, const int w, const int h )
{
   Window *wcur, *wlast, *wdw;

   /* Allocate memory. */
   wdw = malloc( sizeof(Window) );
   memset( wdw, 0, sizeof(Window) );

   const int wid = (++genwid); /* unique id */

   /* Create the window. */

   wdw->id           = wid;
   wdw->name         = strdup(name);

   /* Sane defaults. */
   wdw->idgen        = -1;
   wdw->focus        = -1;

   /* Dimensions. */
   wdw->w            = (w == -1) ? SCREEN_W : (double) w;
   wdw->h            = (h == -1) ? SCREEN_H : (double) h;
   if ((w == -1) && (h == -1)) {
      window_setFlag( wdw, WINDOW_FULLSCREEN );
      wdw->x = 0.;
      wdw->y = 0.;
   }
   else {
      /* x pos */
      if (x==-1) /* center */
         wdw->x = (SCREEN_W - wdw->w)/2.;
      else if (x < 0)
         wdw->x = SCREEN_W - wdw->w + (double) x;
      else wdw->x = (double) x;
      /* y pos */
      if (y==-1) /* center */
         wdw->y = (SCREEN_H - wdw->h)/2.;
      else if (y < 0)
         wdw->y = SCREEN_H - wdw->h + (double) y;
      else wdw->y = (double) y;
   }

   if (toolkit_open==0) { /* toolkit is on */
      SDL_ShowCursor(SDL_ENABLE);
      toolkit_open = 1; /* enable toolkit */
      pause_game();
      gl_defViewport(); /* Reset the default viewport */
   }

   /* Clear key repeat. */
   toolkit_clearKey();

   /* Add to list. */
   wdw->next = NULL;
   if (windows == NULL)
      windows = wdw;
   else {
      for (wcur = windows; wcur != NULL; wcur = wcur->next)
         wlast = wcur;
      wlast->next = wdw;
   }

   return wid;
}
Exemplo n.º 18
0
Arquivo: input.c Projeto: Ttech/naev
/**
 * @brief Runs the input command.
 *
 *    @param keynum The index of the  keybind.
 *    @param value The value of the keypress (defined above).
 *    @param kabs The absolute value.
 */
static void input_key( int keynum, double value, double kabs, int repeat )
{
   unsigned int t;
   HookParam hparam[3];

   /* Repetition stuff. */
   if (conf.repeat_delay != 0) {
      if ((value == KEY_PRESS) && !repeat) {
         repeat_key        = keynum;
         repeat_keyTimer   = SDL_GetTicks();
         repeat_keyCounter = 0;
      }
      else if (value == KEY_RELEASE) {
         repeat_key        = -1;
         repeat_keyTimer   = 0;
         repeat_keyCounter = 0;
      }
   }

   /*
    * movement
    */
   /* accelerating */
   if (KEY("accel") && !repeat) {
      if (kabs >= 0.) {
         if (!paused) player_autonavAbort(NULL);
         player_accel(kabs);
         input_accelButton = 1;
      }
      else { /* prevent it from getting stuck */
         if (value==KEY_PRESS) {
            if (!paused) player_autonavAbort(NULL);
            player_accel(1.);
            input_accelButton = 1;
         }

         else if (value==KEY_RELEASE) {
            player_accelOver();
            input_accelButton = 0;
         }

         /* double tap accel = afterburn! */
         t = SDL_GetTicks();
         if ((conf.afterburn_sens != 0) &&
               (value==KEY_PRESS) && INGAME() && NOHYP() && NODEAD() &&
               (t-input_accelLast <= conf.afterburn_sens))
            player_afterburn();
         else if ((value==KEY_RELEASE) && !input_afterburnerButton)
            player_afterburnOver(0);

         if (value==KEY_PRESS)
            input_accelLast = t;
      }
   /* Afterburning. */
   } else if (KEY("afterburn") && INGAME() && !repeat) {
      if ((value==KEY_PRESS) && NOHYP() && NODEAD()) {
         player_afterburn();
         input_afterburnerButton = 1;
      }
      else if (value==KEY_RELEASE) {
         player_afterburnOver(0);
         input_afterburnerButton = 0;
         if (!input_accelButton)
            player_accelOver();
      }

   /* turning left */
   } else if (KEY("left") && !repeat) {
      if (kabs >= 0.) {
         if (!paused) player_autonavAbort(NULL);
         player_setFlag(PLAYER_TURN_LEFT);
         player_left = kabs;
      }
      else {
         /* set flags for facing correction */
         if (value==KEY_PRESS) {
            if (!paused) player_autonavAbort(NULL);
            player_setFlag(PLAYER_TURN_LEFT);
            player_left = 1.;
         }
         else if (value==KEY_RELEASE) {
            player_rmFlag(PLAYER_TURN_LEFT);
            player_left = 0.;
         }
      }

   /* turning right */
   } else if (KEY("right") && !repeat) {
      if (kabs >= 0.) {
         if (!paused) player_autonavAbort(NULL);
         player_setFlag(PLAYER_TURN_RIGHT);
         player_right = kabs;
      }
      else {
         /* set flags for facing correction */
         if (value==KEY_PRESS) {
            if (!paused) player_autonavAbort(NULL);
            player_setFlag(PLAYER_TURN_RIGHT);
            player_right = 1.;
         }
         else if (value==KEY_RELEASE) {
            player_rmFlag(PLAYER_TURN_RIGHT);
            player_right = 0.;
         }
      }

   /* turn around to face vel */
   } else if (KEY("reverse") && !repeat) {
      if (value==KEY_PRESS) {
         if (!paused) player_autonavAbort(NULL);
         player_setFlag(PLAYER_REVERSE);
      }
      else if ((value==KEY_RELEASE) && player_isFlag(PLAYER_REVERSE))
         player_rmFlag(PLAYER_REVERSE);


   /*
    * combat
    */
   /* shooting primary weapon */
   } else if (KEY("primary") && NODEAD() && !repeat) {
      if (value==KEY_PRESS) {
         player_setFlag(PLAYER_PRIMARY);
      }
      else if (value==KEY_RELEASE)
         player_rmFlag(PLAYER_PRIMARY);
   /* targetting */
   } else if (INGAME() && NODEAD() && KEY("target_next")) {
      if (value==KEY_PRESS) player_targetNext(0);
   } else if (INGAME() && NODEAD() && KEY("target_prev")) {
      if (value==KEY_PRESS) player_targetPrev(0);
   } else if (INGAME() && NODEAD() && KEY("target_nearest")) {
      if (value==KEY_PRESS) player_targetNearest();
   } else if (INGAME() && NODEAD() && KEY("target_nextHostile")) {
      if (value==KEY_PRESS) player_targetNext(1);
   } else if (INGAME() && NODEAD() && KEY("target_prevHostile")) {
      if (value==KEY_PRESS) player_targetPrev(1);
   } else if (INGAME() && NODEAD() && KEY("target_hostile")) {
      if (value==KEY_PRESS) player_targetHostile();
   } else if (INGAME() && NODEAD() && KEY("target_clear")) {
      if (value==KEY_PRESS) player_targetClear();
   /* face the target */
   } else if (KEY("face") && !repeat) {
      if (value==KEY_PRESS) {
         if (!paused) player_autonavAbort(NULL);
         player_setFlag(PLAYER_FACE);
      }
      else if ((value==KEY_RELEASE) && player_isFlag(PLAYER_FACE))
         player_rmFlag(PLAYER_FACE);

   /* board them ships */
   } else if (KEY("board") && INGAME() && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) {
         if (!paused) player_autonavAbort(NULL);
         player_board();
      }


   /*
    * Escorts.
    */
   } else if (INGAME() && NODEAD() && KEY("e_targetNext") && !repeat) {
      if (value==KEY_PRESS) player_targetEscort(0);
   } else if (INGAME() && NODEAD() && KEY("e_targetPrev") && !repeat) {
      if (value==KEY_PRESS) player_targetEscort(1);
   } else if (INGAME() && NODEAD() && KEY("e_attack") && !repeat) {
      if (value==KEY_PRESS) escorts_attack(player.p);
   } else if (INGAME() && NODEAD() && KEY("e_hold") && !repeat) {
      if (value==KEY_PRESS) escorts_hold(player.p);
   } else if (INGAME() && NODEAD() && KEY("e_return") && !repeat) {
      if (value==KEY_PRESS) escorts_return(player.p);
   } else if (INGAME() && NODEAD() && KEY("e_clear") && !repeat) {
      if (value==KEY_PRESS) escorts_clear(player.p);


   /*
    * secondary weapons
    */
   /* shooting secondary weapon */
   } else if (KEY("secondary") && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) {
         player_setFlag(PLAYER_SECONDARY);
      }
      else if (value==KEY_RELEASE)
         player_rmFlag(PLAYER_SECONDARY);

   /* Weapon sets. */
   } else if (KEY("weapset1")) {
      player_weapSetPress( 0, value );
   } else if (KEY("weapset2")) {
      player_weapSetPress( 1, value );
   } else if (KEY("weapset3")) {
      player_weapSetPress( 2, value );
   } else if (KEY("weapset4")) {
      player_weapSetPress( 3, value );
   } else if (KEY("weapset5")) {
      player_weapSetPress( 4, value );
   } else if (KEY("weapset6")) {
      player_weapSetPress( 5, value );
   } else if (KEY("weapset7")) {
      player_weapSetPress( 6, value );
   } else if (KEY("weapset8")) {
      player_weapSetPress( 7, value );
   } else if (KEY("weapset9")) {
      player_weapSetPress( 8, value );
   } else if (KEY("weapset0")) {
      player_weapSetPress( 9, value );

   /*
    * space
    */
   } else if (KEY("autonav") && INGAME() && NOHYP() && NODEAD()) {
      if (value==KEY_PRESS) player_autonavStart();
   /* target planet (cycles like target) */
   } else if (KEY("target_planet") && INGAME() && NOHYP() && NOLAND() && NODEAD()) {
      if (value==KEY_PRESS) player_targetPlanet();
   /* target nearest planet or attempt to land */
   } else if (KEY("land") && INGAME() && NOHYP() && NOLAND() && NODEAD()) {
      if (value==KEY_PRESS) {
         if (!paused) player_autonavAbort(NULL);
         player_land();
      }
   } else if (KEY("thyperspace") && NOHYP() && NOLAND() && NODEAD()) {
      if (value==KEY_PRESS) {
         player_autonavAbort(NULL);
         player_targetHyperspace();
      }
   } else if (KEY("starmap") && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) map_open();
   } else if (KEY("jump") && INGAME() && !repeat) {
      if (value==KEY_PRESS) {
         if (!paused) player_autonavAbort(NULL);
         player_jump();
      }
   } else if (KEY("overlay") && NODEAD() && INGAME() && !repeat) {
      ovr_key( value );


   /*
    * Communication.
    */
   } else if (KEY("log_up") && INGAME() && NODEAD()) {
      if (value==KEY_PRESS) {
         gui_messageScrollUp(5);
      }
   } else if (KEY("log_down") && INGAME() && NODEAD()) {
      if (value==KEY_PRESS) {
         gui_messageScrollDown(5);
      }
   } else if (KEY("hail") && INGAME() && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) {
         player_hail();
      }
   } else if (KEY("autohail") && INGAME() && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) {
         player_autohail();
      }


   /*
    * misc
    */
   /* zooming in */
   } else if (KEY("mapzoomin") && INGAME() && NODEAD()) {
      if (value==KEY_PRESS) gui_setRadarRel(-1);
   /* zooming out */
   } else if (KEY("mapzoomout") && INGAME() && NODEAD()) {
      if (value==KEY_PRESS) gui_setRadarRel(1);
   /* take a screenshot */
   } else if (KEY("screenshot")) {
      if (value==KEY_PRESS) player_screenshot();
   /* pause the games */
   } else if (KEY("pause") && !repeat) {
      if (value==KEY_PRESS) {
         if (!toolkit_isOpen()) {
            if (paused)
               unpause_game();
            else
               pause_game();
         }
      }
   /* toggle speed mode */
   } else if (KEY("speed") && !repeat) {
      if ((value==KEY_PRESS) && !player_isFlag(PLAYER_AUTONAV)) {
         if (!player_isFlag( PLAYER_CINEMATICS_2X )) {
            if (player_isFlag(PLAYER_DOUBLESPEED)) {
               pause_setSpeed(1.);
               player_rmFlag(PLAYER_DOUBLESPEED);
            } else {
               pause_setSpeed(2.);
               player_setFlag(PLAYER_DOUBLESPEED);
            }
         }
      }
   /* opens a small menu */
   } else if (KEY("menu") && NODEAD() && !repeat) {
      if (value==KEY_PRESS) menu_small();

   /* shows pilot information */
   } else if (KEY("info") && NOHYP() && NODEAD() && !repeat) {
      if (value==KEY_PRESS) menu_info( INFO_MAIN );

   /* Opens the Lua console. */
   } else if (KEY("console") && NODEAD() && !repeat) {
      if (value==KEY_PRESS) cli_open();
   }

   /* Key press not used. */
   else {
      return;
   }

   /* Run the hook. */
   hparam[0].type    = HOOK_PARAM_STRING;
   hparam[0].u.str   = input_keybinds[keynum].name;
   hparam[1].type    = HOOK_PARAM_BOOL;
   hparam[1].u.b     = (value > 0.);
   hparam[2].type    = HOOK_PARAM_SENTINAL;
   hooks_runParam( "input", hparam );
}
Exemplo n.º 19
0
/**
 * @brief Opens the system editor interface.
 */
void uniedit_open( unsigned int wid_unused, char *unused )
{
   (void) wid_unused;
   (void) unused;
   unsigned int wid;

   /* Pause. */
   pause_game();

   /* Needed to generate faction disk. */
   map_setZoom( 1. );

   /* Must have no diffs applied. */
   diff_clear();

   /* Reset some variables. */
   uniedit_mode   = UNIEDIT_DEFAULT;
   uniedit_drag   = 0;
   uniedit_dragSys = 0;
   uniedit_tsys   = NULL;
   uniedit_tadd   = 0;
   uniedit_zoom   = 1.;
   uniedit_xpos   = 0.;
   uniedit_ypos   = 0.;

   /* Create the window. */
   wid = window_create( "Universe Editor", -1, -1, -1, -1 );
   window_handleKeys( wid, uniedit_keys );
   uniedit_wid = wid;

   /* Close button. */
   window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnClose", "Close", uniedit_close );

   /* Jump toggle. */
   window_addButton( wid, -20, 20+(BUTTON_HEIGHT+20)*3, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnJump", "Jump", uniedit_btnJump );

   /* Rename system. */
   window_addButton( wid, -20, 20+(BUTTON_HEIGHT+20)*4, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnRename", "Rename", uniedit_btnRename );

   /* Edit system. */
   window_addButton( wid, -20, 20+(BUTTON_HEIGHT+20)*5, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnEdit", "Edit", uniedit_btnEdit );

   /* New system. */
   window_addButton( wid, -20, 20+(BUTTON_HEIGHT+20)*6, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnNew", "New Sys", uniedit_btnNew );

   /* Open a system. */
   window_addButton( wid, -20, 20+(BUTTON_HEIGHT+20)*7, BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnOpen", "Open", uniedit_btnOpen );

   /* Zoom buttons */
   window_addButton( wid, 40, 20, 30, 30, "btnZoomIn", "+", uniedit_buttonZoom );
   window_addButton( wid, 80, 20, 30, 30, "btnZoomOut", "-", uniedit_buttonZoom );

   /* Presence. */
   window_addText( wid, -20, -140, 90, 20, 0, "txtSPresence",
         &gl_smallFont, &cDConsole, "Presence:" );
   window_addText( wid, -20, -140-gl_smallFont.h-5, 80, 100, 0, "txtPresence",
         &gl_smallFont, &cBlack, "N/A" );

   /* Selected text. */
   window_addText( wid, 140, 10, SCREEN_W - 80 - 30 - 30 - BUTTON_WIDTH - 20, 30, 0,
         "txtSelected", &gl_smallFont, &cBlack, NULL );

   /* Actual viewport. */
   window_addCust( wid, 20, -40, SCREEN_W - 150, SCREEN_H - 100,
         "cstSysEdit", 1, uniedit_render, uniedit_mouse, NULL );
   window_custSetOverlay( wid, "cstSysEdit", uniedit_renderOverlay );

   /* Deselect everything. */
   uniedit_deselect();
}
Exemplo n.º 20
0
/*
 * main -- Main program.
 */
int main(void) {
	uint8_t chars_into_escape_sequence = 0;
	int8_t moveStatus = 0;

	char c;

	/* Initialise our main clock */
	init_timer();

	/* Initialise serial I/O */
	init_serial_stdio(19200, 0);

	/* Make the display_row() function be called every 2ms.
	** (This function returns a timer number, but we ignore 
	** this since we'll never do anything with it.)
	*/
	execute_function_periodically(2, display_row);

	/* Register the time_increment() function to be called every 500ms.
	** This function just sets a variable (timePassedFlag).
	*/
	mainTimerNum = execute_function_periodically(500, time_increment);

	//4209435
	/* setup AVR to handle sounds*/
	init_sound();

	/*
	** Turn on interrupts (needed for timer and serial input/output to work)
	*/
	sei();
	
	/*
	** Display splash screen 
	*/
	splash_screen();
	show_instruction(NEWGAME);
	
	/*
	** Perform necessary initialisations for a new game.
	*/
	new_game();
		
	/*
	** Event loop - wait for a certain amount of time to pass or wait
	** for a character to arrive from standard input. The time_passed_flag
	** is set within the function time_increment() below - which is setup
	** to be called periodically.
	*/
	for(;;) {
		if(timePassedFlag) {
			moveStatus = move_snake();
			timePassedFlag = 0;
		} else if(input_available()) {
			/* Read the input from our terminal and handle it */
			c = fgetc(stdin);			
			if(chars_into_escape_sequence == 0 && c == '\x1b') {
				/*
				** Received ESCAPE character - we're one character into
				** an escape sequence
				*/
				chars_into_escape_sequence = 1;
			} else if(chars_into_escape_sequence == 1 && c == '[') {
				/* 
				** We're now two characters into an escape sequence
				*/
				chars_into_escape_sequence = 2;
			} else if (chars_into_escape_sequence == 2) {
				/* We're two characters into an escape sequence and
				** have received another - see if it is as expected.
				*/
				if (c == 'C') {
					/* Cursor right key pressed - Set next direction to
					** be moved to RIGHT */
					set_snake_dirn(RIGHT);
				}  
				if (c == 'D') {
					/* Cursor left key pressed - Set next direction to
					** be moved to LEFT */
					set_snake_dirn(LEFT);
				}  
				if (c == 'A') {
					/* Cursor up key pressed - Set next direction to
					** be moved to UP */
					set_snake_dirn(UP);
				}  
				if (c == 'B') {
					/* Cursor down key pressed - Set next direction to
					** be moved to DOWN */
					set_snake_dirn(DOWN);
				}

				/* else, unknown escape sequence */

				/* We're no longer part way through an escape sequence */
				chars_into_escape_sequence = 0; 
			} else if(chars_into_escape_sequence != 0) {
				/*
				** We started an escape sequence but didn't get a character
				** we recognised - discard it and assume that we're not
				** in an escape sequence.
				*/
				chars_into_escape_sequence = 0;
			} else if (c == ' ') {
				/* Space character received - move snake immediately */
				moveStatus = move_snake();
			} else {					
				if(c == 'N' || c == 'n'){	
					show_instruction(NEWGAME);				
					new_game();
				} else if(c == 'P' || c == 'p'){
					moveStatus = 0;
					pause_game();
				} else if(c == 'M' || c == 'm'){
					toggle_sound();
					display_sound_status();
				}
			}
		}

		switch(moveStatus){
			case ATE_FOOD:
				if(sound_status())
					play_sound();
				moveStatus = MOVE_OK;
				break;
		}

		if(moveStatus < 0) {
			/* Move failed - game over */
			handle_game_over();
			moveStatus = 0;
			update_score();
		}
	}
}
Exemplo n.º 21
0
void WindowPlanes::planes_dit()
{
    pause_game();
    planes->remove_me();
}
Exemplo n.º 22
0
Arquivo: menu.c Projeto: naev/naev
/**
 * @brief Hack to get around the fact the death menu unpauses the game.
 */
static void menu_death_close( unsigned int wid, char* str )
{
   (void) wid;
   (void) str;
   pause_game(); /* Repause the game. */
}
Exemplo n.º 23
0
Arquivo: help.c Projeto: lollek/imoria
void help()
{
  /*{ Help for available commands                                       }*/

  char      command;

  inkey_delay(&command,0);
  if (command == 0) {
      clear_screen();
prt("A       Age of character.     |  h       Hurl an item.",1,1);
prt("B <Dir> Bash (object/creature)|  i       Inventory list.",2,1);
prt("C       Display character.    |  j <Dir> Jam a door with spike.",3,1);
inkey_delay(&command,0);
if (command == 0) {
prt("D <Dir> Disarm a trap/chest.  |  l <Dir> Look given direction.",4,1);
prt("E       Eat some food.        |  m       Cast a magic spell.",5,1);
prt("F       Fill lamp with oil.   |  m       Use a music book.",6,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("G       Game time and date    |  o <Dir> Open a door/chest.",7,1);
prt("H       Help                  |  p       Read a prayer.",8,1);
prt("I       Inven of one item type|  p       Play an instrument.",9,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("L       Current location.     |  q       Quaff a potion.",10,1);
prt("M       Money.                |  r       Read a scroll.",11,1);
prt("P       Print map.            |  s       Search for hidden doors.",12,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("R       Rest for a period.    |  t       Take off an item.",13,1);
prt("S       Search Mode.          |  u       Use a staff.",14,1);
prt("T <Dir> Tunnel.               |  v       Version and credits.",15,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("U       Use miscellaneous item|  w       Wear/Wield an item.",16,1);
prt("W       Current time and date |  x       Exchange weapon.",17,1);
prt("a       Aim and fire a wand.  |  c <inv> Clean inventory.",18,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("b       Browse a book.        |  $       Shell out of game.",19,1);
prt("c <Dir> Close a door.         |  +       Experience for levels.",20,1);
prt("d       Drop an item.         |  . <Dir> Move in direction.",21,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("e       Equipment list.       |  /       Identify a character.",22,1);
prt("f       Fire Projectile.      |  X       Toggle light source.",23,1);

      pause_game(24);
}
clear_screen();
inkey_delay(&command,0);
if (command == 0) {
prt("<       Go up an up-staircase.|   >      Go down a down-staircase.",1,1);
prt("?       Display this panel.   |  ^M      Repeat the last message.",2,1);
prt("]       Armor list.           |  ^R      Redraw the screen.",3,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("|       Weapon list.          |  ^C      Quit the game.",4,1);
prt("J       Map shown reduced size|  ^Y      Save character and quit.",5,1);
prt("Movement:",7,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("          7  8  9",8,1);
prt("          4     6    5 = Rest",9,1);
prt("          1  2  3",10,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("Directory of Shops:",12,1);
prt("     A   Alchemy Shop                M   Magic Shop",13,1);
prt("     B   Bank                        P   Trading Post",14,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("     C   Casino                      Q   Questor's Home",15,1);
prt("     D   All-Nite Deli               R   Armory",16,1);
prt("     G   General Store               T   Temple",17,1);
inkey_delay(&command,0);
}
if (command == 0) {
prt("     I   Inn                         U   Music Shop",18,1);
prt("     J   Gem Shop                    W   Weapon Smith",19,1);
prt("     L   Library                     X   Money Exchange",20,1);
prt("     +   Unknown",21,1);
      pause_game(24);
}
draw_cave();
  }
};
Exemplo n.º 24
0
int humanvspsp(Player *p1, Player *p2)
{
	BITMAP* buffer_field_game = create_bitmap(MAX_WIDTH, MAX_HEIGTH);
	BITMAP* buffer_border_and_info = create_bitmap(SCREEN_WIDTH, SCREEN_HEIGTH);
	int koniec = -1;

	reset_player(p1, 136, 230, 2);
	reset_player(p2, 136, 245, 3);

	clear_to_color(buffer_field_game, makecol(0, 0, 0));
	rysuj_obramowanie(buffer_border_and_info, p1, p2);
	blit(buffer_border_and_info, screen, 0, 0, 0, 0, buffer_border_and_info->w, buffer_border_and_info->h);
	clear_keybuf();

	odliczanie();

	blit(buffer_border_and_info, screen, 0, 0, 0, 0, buffer_border_and_info->w, buffer_border_and_info->h);

	clear_key();

	blit(buffer_field_game, buffer_border_and_info, 0, 0, 1, 1, buffer_field_game->w, buffer_field_game->h);
	blit(buffer_border_and_info, screen, 0, 0, 0, 0, buffer_border_and_info->w, buffer_border_and_info->h);

	p1_speed = 0;
	p2_speed = 0;
	speed = 25;
	install_int_ex(p1_speed_func, MSEC_TO_TIMER(speed));
	install_int_ex(p2_speed_func, MSEC_TO_TIMER(speed));
	install_int_ex(speed_func, SECS_TO_TIMER(1));

	while(TRUE)
	{
		ai_run(p2, buffer_field_game);
		if((p1->x == p2->x) && (p1->y == p2->y))
		{
			koniec = 0;
			break;
		}


		switch(p1->direction)
		{
			case UP:
				if(getpixel(buffer_field_game, p1->y, p1->x-1) != makecol(0, 0, 0))
				{
					koniec = 1;
				}
			break;
			case DOWN:
				if(getpixel(buffer_field_game, p1->y, p1->x+1) != makecol(0, 0, 0))
				{
					koniec = 1;
				}
			break;
			case LEFT:
				if(getpixel(buffer_field_game, p1->y-1, p1->x) != makecol(0, 0, 0))
				{
					koniec = 1;
				}
			break;
			case RIGHT:
				if(getpixel(buffer_field_game, p1->y+1, p1->x) != makecol(0, 0, 0))
				{
					koniec = 1;
				}
			break;
		}

		switch(p2->direction)
		{
			case UP:
				if(getpixel(buffer_field_game, p2->y, p2->x-1) != makecol(0, 0, 0))
				{
					if(koniec == 1)
					{
						koniec = 0;
						break;
					}
					else
					{
						koniec = 2;
					}
				}
			break;
			case DOWN:
				if(getpixel(buffer_field_game, p2->y, p2->x+1) != makecol(0, 0, 0))
				{
					if(koniec == 1)
					{
						koniec = 0;
						break;
					}
					else
					{
						koniec = 2;
					}
				}
			break;
			case LEFT:
				if(getpixel(buffer_field_game, p2->y-1, p2->x) != makecol(0, 0, 0))
				{
					if(koniec == 1)
					{
						koniec = 0;
						break;
					}
					else
					{
						koniec = 2;
					}
				}
			break;
			case RIGHT:
				if(getpixel(buffer_field_game, p2->y+1, p2->x) != makecol(0, 0, 0))
				{
					if(koniec == 1)
					{
						koniec = 0;
						break;
					}
					else
					{
						koniec = 2;
					}
				}
			break;
		}

		putpixel(buffer_field_game, p1->y, p1->x, makecol(255, 255, 255));
		putpixel(buffer_field_game, p2->y, p2->x, makecol(86, 160, 222));

		if(p1->x < MIN_HEIGTH || p1->x > MAX_HEIGTH-1 || p1->y < MIN_WIDTH || p1->y > MAX_WIDTH-1)
		{
			koniec = 1;
		}

		if(p2->x < MIN_HEIGTH || p2->x > MAX_HEIGTH-1 || p2->y < MIN_WIDTH || p2->y > MAX_WIDTH-1)
		{
			if(koniec == 1)
			{
				koniec = 0;
				break;
			}
			else
			{
				koniec = 2;
			}
		}

		blit(buffer_field_game, screen, 0, 0, 1, 1, buffer_field_game->w, buffer_field_game->h);

		if(koniec != -1)
			break;


		if(key[KEY_ESC])
			break;

		if(key[KEY_ENTER])
		{
			pause_game(0, p1, p2);
			odliczanie();
		}

#ifdef PSP
		if(key[KEY_RSHIFT])
		{
			thid = sceKernelCreateThread("Screenshotpsp", screenshotpsp,
			   0x11, 256 * 1024, PSP_THREAD_ATTR_USER, NULL);
			sceKernelStartThread(thid, 0, NULL);
		}
#else
		if(key[KEY_M])
		{
			screenshot();
		}
#endif

#if PSP
		if(key[KEY_UP])
#else
		if(key[KEY_W])
#endif
		{
			if(p1->direction != DOWN)
				p1->direction = UP;
		}
#if PSP
		else if(key[KEY_DOWN])
#else
		else if(key[KEY_S])
#endif
		{
			if(p1->direction != UP)
				p1->direction = DOWN;
		}
#if PSP
		else if(key[KEY_LEFT])
#else
		else if(key[KEY_A])
#endif
		{
			if(p1->direction != RIGHT)
				p1->direction = LEFT;
		}
#if PSP
		else if(key[KEY_RIGHT])
#else
		else if(key[KEY_D])
#endif
		{
			if(p1->direction != LEFT)
				p1->direction = RIGHT;
		}
		clear_keybuf();
		keypressed();


		while(p1_speed > 0)
		{
			switch(p1->direction)
			{
				case UP:
					p1->x--;
				break;
				case DOWN:
					p1->x++;
				break;
				case LEFT:
					p1->y--;
				break;
				case RIGHT:
					p1->y++;
				break;
			}
			p1_speed--;
		}

		while(p2_speed > 0)
		{
			switch(p2->direction)
			{
				case UP:
					p2->x--;
				break;
				case DOWN:
					p2->x++;
				break;
				case LEFT:
					p2->y--;
				break;
				case RIGHT:
					p2->y++;
				break;
			}
			p2_speed--;
		}

	}

	remove_int(p1_speed_func);
	remove_int(p2_speed_func);
	remove_int(speed_func);

	destroy_bitmap(buffer_field_game);
	destroy_bitmap(buffer_border_and_info);

	return koniec;
}
Exemplo n.º 25
0
// Controls the player input
void
ctrl_player(WINDOWLIST * lw, PLAYER * p)
{
  char input;

  set_inputmode(IM_PLAYING);
  if (g_fld[p->x][p->y] != ENT_PLAYER)
  {
    g_fld[p->x][p->y] = ENT_PLAYER;
  }

  input = (char) getch();
  if (input == cfg->up)
  {
    p->ch = '^';
    if (p->y > CON_FIELDMINY)
    {
      mv_player(lw, p, DIR_UP);
    }
    else
    {
      set_winchar(lw->w_field, p->x, p->y, A_BOLD, CP_WHITEBLACK, p->ch);
    }
  }
  else if (input == cfg->down)
  {
    p->ch = 'v';
    if (p->y < CON_FIELDMAXY)
    {
      mv_player(lw, p, DIR_DOWN);
    }
    else
    {
      set_winchar(lw->w_field, p->x, p->y, A_BOLD, CP_WHITEBLACK, p->ch);
    }
  }
  else if (input == cfg->left)
  {
    p->ch = '<';
    if (p->x > CON_FIELDMINX)
    {
      mv_player(lw, p, DIR_LEFT);
    }
    else
    {
      set_winchar(lw->w_field, p->x, p->y, A_BOLD, CP_WHITEBLACK, p->ch);
    }
  }
  else if (input == cfg->right)
  {
    p->ch = '>';
    if (p->x < CON_FIELDMAXX)
    {
      mv_player(lw, p, DIR_RIGHT);
    }
    else
    {
      set_winchar(lw->w_field, p->x, p->y, A_BOLD, CP_WHITEBLACK, p->ch);
    }
  }
  else if (input == cfg->use)
  {
    set_player_dmg(lw->w_field, p, 10); // Just for testing purposes
  }
  else if (input == cfg->nextw)
  {
    // Next weapon
  }
  else if (input == cfg->prevw)
  {
    // Previous weapon
  }
  else if (input == cfg->inv)
  {
    show_inventory();
    redrawwin(lw->w_field);
    redrawwin(lw->w_game);
    redrawwin(lw->w_status);
    wrefresh(lw->w_field);
    wrefresh(lw->w_game);
    wrefresh(lw->w_status);
  }
  else if (input == '\n')
  {
    p->quit = true;
  }
  else if (input == 'p') // Just for debug purposes, will be removed later on
  {
    int t_freeze;

    t_freeze = pause_game();
    set_inputmode(IM_KEYPRESS);
    while(getch() != '\n');
    resume_game(t_freeze);
  }
  else if (input == ERR)
  {
    /* Since we use nodelay(), getch() returns ERR when no key is pressed
     * (instead of blocking everything else), however this leads to 100%
     * cpu usage. Thus, usleep is used to calm down the cpu. */
    usleep(500);
  }

  if (p->hp == 0)
  {
    write_log(LOG_INFO, "%s:\n\tPlayer is dead, stopping game ...\n", __func__);
    p->quit = true;
  }
}