tmp commit
This commit is contained in:
parent
a2c9d40d4d
commit
b8c29cad9d
3
README
3
README
@ -13,3 +13,6 @@ Afin de limiter l'utilisation du mot const (pour garder une certaine lisibilité
|
||||
|
||||
|
||||
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)'
|
||||
|
@ -9,6 +9,9 @@ struct Player{
|
||||
|
||||
unsigned deathAnimCounter=0;
|
||||
unsigned fireCooldown=0;
|
||||
|
||||
// TODO remove ?
|
||||
bool isEliminated();
|
||||
};
|
||||
|
||||
#endif
|
@ -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;i<players[pID].lives;++i){
|
||||
pm.drawHeart(Position(x, y));
|
||||
y+=HEART_LENGTH+5;
|
||||
}
|
||||
if(players[pID].deathAnimCounter>0){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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<players.size();++i)manageOnePlayer(i);
|
||||
}
|
||||
|
||||
/** Makes the invaders play once, and check lower bounds
|
||||
|
5
src/player.cpp
Normal file
5
src/player.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "player.h"
|
||||
|
||||
bool Player::isEliminated() {
|
||||
return lives == 0 && deathAnimCounter == 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user