From 3f38bf4ac22f10373b99aab341e5758b9b16c8e4 Mon Sep 17 00:00:00 2001 From: mibi88 <76903855+mibi88@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:38:58 +0200 Subject: [PATCH] Very simple player selection --- CMakeLists.txt | 1 + assets-cg/fxconv-metadata.txt | 3 --- assets-fx/fxconv-metadata.txt | 4 ++-- src/game.c | 8 ++++++++ src/game.h | 1 + src/main.c | 2 +- src/player.c | 6 ++++-- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be3b00f..94eeb0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ set(ASSETS_cg_EGA64 set(ASSETS_fx assets-fx/player_male.png + assets-fx/player_female.png assets-fx/npc/char/npc_male.png assets-fx/npc/char/npc_female.png assets-fx/npc/char/npc_milkman.png diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt index 406fdaf..86e8216 100644 --- a/assets-cg/fxconv-metadata.txt +++ b/assets-cg/fxconv-metadata.txt @@ -4,9 +4,6 @@ profile: p8 scale: 1 -player_male.png: - name: demo_player_img - font.png: name: fontRPG custom-type: font diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt index 25201a7..1020805 100644 --- a/assets-fx/fxconv-metadata.txt +++ b/assets-fx/fxconv-metadata.txt @@ -1,9 +1,9 @@ player_male.png: type: bopti-image - name: demo_player_img + name: player_male_img player_female.png: type: bopti-image - name: player_female + name: player_female_img player_face.png: type: bopti-image diff --git a/src/game.c b/src/game.c index 2f7cb7a..dd2bb1c 100644 --- a/src/game.c +++ b/src/game.c @@ -114,6 +114,14 @@ void game_get_inputs(Game *game) { 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); + if(keydown(KEY_OPTN)){ + game->player.is_male = !game->player.is_male; + /* TODO: Make something cleaner */ + while(keydown(KEY_OPTN)){ + clearevents(); + sleep(); + } + } /* Display Debug Information on screen */ #if DEBUGMODE diff --git a/src/game.h b/src/game.h index 07df01a..77fb3a7 100644 --- a/src/game.h +++ b/src/game.h @@ -43,6 +43,7 @@ typedef struct { bool isDoingAction; /* the player is interacting with a NPC */ bool isInteractingWithNPC; + bool is_male; } Player; diff --git a/src/main.c b/src/main.c index 8055976..76655fd 100644 --- a/src/main.c +++ b/src/main.c @@ -36,7 +36,7 @@ extern Map *worldRPG[]; /* Game data (defined in "game.h")*/ Game game = { NULL, - {12*PXSIZE, 36*PXSIZE, 0, 0, 12*PXSIZE, 36*PXSIZE, 100, SPEED, false, 0, false, false}, + {12*PXSIZE, 36*PXSIZE, 0, 0, 12*PXSIZE, 36*PXSIZE, 100, SPEED, false, 0, false, false, true}, {{}, {}, 0}, false, false, false, 0 diff --git a/src/player.c b/src/player.c index 9578c66..dbb443a 100644 --- a/src/player.c +++ b/src/player.c @@ -6,7 +6,8 @@ #include "npc.h" #include -extern bopti_image_t demo_player_img; +extern bopti_image_t player_male_img; +extern bopti_image_t player_female_img; extern bopti_image_t npc_male; extern bopti_image_t npc_female; extern bopti_image_t npc_milkman; @@ -50,7 +51,8 @@ extern uint32_t nbNPC; void player_draw(Game *game) { Player *player = &game->player; - dimage(player->px-P_WIDTH/2, player->py-P_HEIGHT/2, &demo_player_img); + dimage(player->px-P_WIDTH/2, player->py-P_HEIGHT/2, + player->is_male ? &player_male_img : &player_female_img); } void player_move(Game *game, Direction direction) {