Collab_RPG/src/game.c

53 lines
1.4 KiB
C
Raw Normal View History

#include "game.h"
#include "map.h"
#include "config.h"
#include <gint/keyboard.h>
void game_logic(Game *game) {
// to be done
}
void draw(Game *game) {
2023-07-08 16:57:04 +02:00
/* Draw everything. */
render_map_by_layer(&game->player, game->map_level, BACKGROUND);
player_draw(&game->player);
render_map_by_layer(&game->player, game->map_level, FOREGROUND);
}
/* Key management */
void get_inputs(Game *game) {
key_event_t ev;
while((ev = pollevent()).type != KEYEV_NONE){
/**/
}
/* Key binding for the Player action */
/*************************************/
if(keydown(KEY_EXIT)) game->exittoOS = true;
/* Player actions - Prototypes in player.h and implementation in player.c */
if(keydown(KEY_LEFT)) player_move(game->map_level, &game->player, D_LEFT);
if(keydown(KEY_RIGHT)) player_move(game->map_level, &game->player, D_RIGHT);
if(keydown(KEY_UP)) player_move(game->map_level, &game->player, D_UP);
if(keydown(KEY_DOWN)) player_move(game->map_level, &game->player, D_DOWN);
if(keydown(KEY_SHIFT)) player_action(&game->player);
if(keydown(KEY_F1)) game->debug_map = !game->debug_map;
if(keydown(KEY_F2)) game->debug_player = !game->debug_player;
/* if USB is enabled - keybinding for screencapture */
#if USB_FEATURE
if(keydown(KEY_7)) game->screenshot = true;
if(keydown(KEY_8)) game->record = !game->record;
#endif //USB_FEATURE
}