2023-07-08 15:55:06 +02:00
|
|
|
#include "game.h"
|
|
|
|
|
|
|
|
#include "map.h"
|
|
|
|
|
2023-07-08 20:07:34 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gint/keyboard.h>
|
2023-08-11 12:23:07 +02:00
|
|
|
#include <gint/cpu.h>
|
2023-07-08 20:07:34 +02:00
|
|
|
|
2023-07-08 15:55:06 +02:00
|
|
|
void game_logic(Game *game) {
|
|
|
|
// to be done
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw(Game *game) {
|
2023-07-08 16:57:04 +02:00
|
|
|
/* Draw everything. */
|
2023-08-11 08:54:04 +02:00
|
|
|
render_map_by_layer(game, BACKGROUND);
|
|
|
|
player_draw(game);
|
|
|
|
render_map_by_layer(game, FOREGROUND);
|
2023-07-08 15:55:06 +02:00
|
|
|
}
|
|
|
|
|
2023-07-08 20:07:34 +02:00
|
|
|
/* 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 */
|
2023-08-11 08:54:04 +02:00
|
|
|
if(keydown(KEY_LEFT)) player_move(game, D_LEFT);
|
|
|
|
if(keydown(KEY_RIGHT)) player_move(game, D_RIGHT);
|
|
|
|
if(keydown(KEY_UP)) player_move(game, D_UP);
|
|
|
|
if(keydown(KEY_DOWN)) player_move(game, D_DOWN);
|
|
|
|
if(keydown(KEY_SHIFT)) player_action(game);
|
|
|
|
|
|
|
|
/* Display Debug Information on screen */
|
|
|
|
#if DEBUGMODE
|
2023-08-11 12:23:07 +02:00
|
|
|
if(keydown(KEY_F1)) {
|
|
|
|
game->debug_map = !game->debug_map;
|
|
|
|
}
|
|
|
|
if(keydown(KEY_F2)) {
|
|
|
|
game->debug_player = !game->debug_player;
|
|
|
|
}
|
2023-08-11 08:54:04 +02:00
|
|
|
#endif
|
2023-07-08 20:07:34 +02:00
|
|
|
|
|
|
|
|
2023-08-11 08:54:04 +02:00
|
|
|
/* if USB is enabled - keybinding for screencapture */
|
2023-07-18 19:47:47 +02:00
|
|
|
#if USB_FEATURE
|
2023-07-08 20:07:34 +02:00
|
|
|
|
|
|
|
if(keydown(KEY_7)) game->screenshot = true;
|
|
|
|
if(keydown(KEY_8)) game->record = !game->record;
|
|
|
|
|
|
|
|
#endif //USB_FEATURE
|
|
|
|
}
|
|
|
|
|