18void Game::displayAll(
unsigned fps)
const {
19 pm->drawSprite(pm->gameBackground,
Position(0, 0));
20 for (
unsigned i = 0; i < this->grid.size(); ++i){
21 for (
unsigned j = 0; j < this->grid[i].size(); ++j){
26 displayInvader(vec, grid[i][j]);
30 for(
const missile& miss : missiles){
33 for(
const Torpedo& tor : torpedos){
41 pm->drawText(
Position(pm->getScreenWidth()-200, 20),
"FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13);
45 for(
unsigned i=0;i<players.size();++i){
46 pm->drawText(
Position(0,10+margin),
"player "+to_string(i+1)+
" :",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
47 pm->drawText(
Position(100,10+margin),to_string(players[i].score) ,nsGraphics::KWhite,Font::BITMAP_8_BY_13);
50 if(!players[i].isEliminated()){
51 if(players[i].deathAnimCounter%2==0){
60void Game::displayHearts(
playerID pID)
const {
68 for(
unsigned i=0;i<players[pID].lives;++i){
72 if(players[pID].hasDeathAnimation()){
73 pm->drawHeart(
Position(x, y+players[pID].deathAnimCounter*5));
97 pos += (point-pos)*percent;
100void Game::displayGod()
const {
109 pm->drawSprite(pm->leftHand, leftHand);
110 pm->drawSprite(pm->rightHand, rightHand);
118 pm->drawSprite(pm->leftHand, leftHand);
119 pm->drawSprite(pm->rightHand, rightHand);
138 pm->drawSprite(pm->rightHand, pos);
158 invaderPos = invaderPos + a;
163 unsigned handCounter;
165 else handCounter = 30-god.
counter;
166 handPos = handPos + god.
thrownVector * (handCounter / 100.0);
168 pm->drawSprite(pm->rightHand, handPos);
unsigned counter
timer used differently in all states
unsigned thrownInvPosY
y index (invader in the column) of the invader thrown by the hand of god
Position thrownTransition
position of a point for bezier's curve (used in RETRIEVE1 and RETRIEVE2 states, for the hand animatio...
Position getRightHandPos(unsigned screenWidth) const
give initial the pixel coordinates of god's right hand
Position thrownVector
direction of the thrown invader movement
GodState state
god's current state
InvaderType thrownInvType
type of the invader thrown by the hand of god
unsigned thrownInvPosX
x index (column in the grid) of the invader thrown by the hand of god
void applyBezierCurbe(Position &pos, const Position &point, const double percent)
full game logic and display management
#define GOD_HAND_DISTANCE
InvaderType
List of all invader type.
unsigned missilesWidth
invaders missiles width in pixel
nsGraphics::RGBAcolor torpedosColor
players torpedos color
vector< PlayerDef > playerDefs
players configuration
unsigned invadersDistance
distance in pixel between two invader
nsGraphics::RGBAcolor missilesColor
invaders missiles color
unsigned playersWidth
player horizontal size in pixel
unsigned invadersSize
invader radius size in pixel
unsigned torpedosWidth
players torpedos width in pixel
map< InvaderType, InvaderTypeDef > invadersDef
link between an invader type, and its data
nsGraphics::RGBAcolor color
color of the invader type
void applyTransformation(Position &pos, unsigned sizeFrom, unsigned sizeTo)
change the position object to reflect the top-right position of a "sizeTo"-sized entity,...
nsGraphics::Vec2D Position