From b8c29cad9d6b3cd57fbd5c4a035f67d36b4276ec Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 8 Jan 2022 14:38:46 +0100 Subject: [PATCH] tmp commit --- README | 5 ++++- headers/player.h | 3 +++ src/game/display.cpp | 10 +++++++--- src/game/gameManagers.cpp | 25 ++++++++++++++++++++----- src/player.cpp | 5 +++++ 5 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 src/player.cpp diff --git a/README b/README index 02eaf55..6d39110 100644 --- a/README +++ b/README @@ -12,4 +12,7 @@ Afin de limiter l'utilisation du mot const (pour garder une certaine lisibilité écran : constante 1280x720 -Reminder : les missiles sont tirés par les envahisseurs, et les torpilles par le joueur \ No newline at end of file +Reminder : les missiles sont tirés par les envahisseurs, et les torpilles par le joueur + +Quelques unes des problèmes rencontrés : +- La sépararation entre l'affichage et la logique nous force à calculer les positions 2 fois (pour le bounc checking, et le l'affichage)' diff --git a/headers/player.h b/headers/player.h index eaf7ab8..4b90cc1 100644 --- a/headers/player.h +++ b/headers/player.h @@ -9,6 +9,9 @@ struct Player{ unsigned deathAnimCounter=0; unsigned fireCooldown=0; + + // TODO remove ? + bool isEliminated(); }; #endif \ No newline at end of file diff --git a/src/game/display.cpp b/src/game/display.cpp index 80c7f82..49313cd 100644 --- a/src/game/display.cpp +++ b/src/game/display.cpp @@ -41,12 +41,16 @@ void Game::displayAll(unsigned fps) const { } void Game::displayHearts(playerID pID) const { - unsigned baseX; - if(pID==PLAYER1)baseX = 0; - else baseX = pm.getScreenWidth()-HEART_LENGTH; + unsigned x; + if(pID==PLAYER1)x = 0; + else x = pm.getScreenWidth()-HEART_LENGTH; unsigned y = GOD_BENCH_SIZE+5; for(unsigned i=0;i0){ } } diff --git a/src/game/gameManagers.cpp b/src/game/gameManagers.cpp index 73c3818..5160727 100644 --- a/src/game/gameManagers.cpp +++ b/src/game/gameManagers.cpp @@ -2,6 +2,25 @@ #define ISPRESSED(ID, X) window.isPressed({confData.playerDefs[ID].keys.X, false}) void Game::manageOnePlayer(playerID pID){ + // manage death + + // we do not use isEliminated here because we can handle it better with if/else + + + /* + * lives = 0 && counter == 0 -> elim + * lives = 1 && counter == 0 -> play + * lives = 0 && counter == 1 -> anim + * lives = 1 && counter == 1 -> anim + */ + + if(players[pID].deathAnimCounter==0){ + if(players[pID].lives==0)return; + }else{ + ++players[pID].deathAnimCounter; + } + + if (ISPRESSED(pID, left)){ if(players[pID].x < confData.playersSpeed) players[pID].x = 0; else players[pID].x -= confData.playersSpeed; @@ -21,11 +40,7 @@ void Game::manageOnePlayer(playerID pID){ /** Makes the players play once */ void Game::managePlayers(){ - manageOnePlayer(0); - if(playMode==PlayMode::TWO_LOCAL)manageOnePlayer(1); - else if(playMode==PlayMode::TWO_TCPIP){ - // TODO TCPIP - } + for(unsigned i=0;i