From a515cb497c109a533d73475be8ea6df6bdeafd96 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 6 Sep 2015 13:45:56 +0200 Subject: Removed some buildings made network more efficient Also decreased number of sensors. --- src/game_state.cpp | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src/game_state.cpp') diff --git a/src/game_state.cpp b/src/game_state.cpp index c6e5d70..29bd75b 100644 --- a/src/game_state.cpp +++ b/src/game_state.cpp @@ -140,15 +140,15 @@ int getRectangularOffset(int width, int x, int y) std::vector GameState::toBitArray() const { - std::vector result(102); + std::vector result(61); - int alienOffset = 0; //Aliens are 0 to 70 - int bulletOffset = 71; //Bullets are 71 to 90 - int shieldOffset = 91; //Shields are 91 to 93 - int missileOffset = 94; //Missile info is 94 to 95 - int positionOffset = 96; //Position is 96 to 98 - int existingBuildingsOffset = 99; //Existing buildings is 99 to 100 - int canBuildOffset = 101; //Can build here is 101 + int alienOffset = 0; //Aliens are 0 to 35 + int bulletOffset = 36; //Bullets are 36 to 50 + int shieldOffset = 51; //Shields are 51 to 53 + int missileOffset = 54; //Missile info is 54 to 55 + int positionOffset = 56; //Position is 56 to 58 + int existingBuildingsOffset = 59; //Existing buildings is 59 + int canBuildOffset = 60; //Can build here is 60 int playerX = GAME_WIDTH/2; int playerY = GAME_AREA_LINES-3; @@ -157,20 +157,19 @@ std::vector GameState::toBitArray() const playerX = _playerSpaceship->x(); } - for (auto const& alien : _aliens) { - if (alien.y() >= playerY || alien.y() < playerY-9) + if (alien.y() > playerY-4 || alien.y() < playerY-7 || alien.x() > playerX+4 || alien.x() < playerX-4) { continue; } - result.at(alienOffset + getPyramidOffset(3, 9, alien.x()-playerX, playerY-1-alien.y(), 69, 70)) = true; + result.at(alienOffset + getRectangularOffset(9, alien.x()-playerX, playerY-4-alien.y())) = true; } for (auto const& bullet : _bullets) { - if (bullet.y() >= playerY || bullet.y() < playerY-4 || bullet.x() > playerX+2 || bullet.x() < playerX-2) + if (bullet.y() >= playerY || bullet.y() < playerY-3 || bullet.x() > playerX+2 || bullet.x() < playerX-2) { continue; } @@ -230,18 +229,6 @@ std::vector GameState::toBitArray() const result.at(canBuildOffset) = false; } } - for (auto const& alienFactory : _alienFactories) - { - if (alienFactory.y() < playerY) - { - continue; - } - result.at(existingBuildingsOffset + 1) = true; - if (abs(alienFactory.x() - playerX) < 3) - { - result.at(canBuildOffset) = false; - } - } return result; } -- cgit v1.2.3