summaryrefslogtreecommitdiff
path: root/src/game_state.cpp
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2015-09-06 13:45:56 +0200
committerJustin Worthe <justin.worthe@gmail.com>2015-09-06 13:45:56 +0200
commita515cb497c109a533d73475be8ea6df6bdeafd96 (patch)
treed719baffaf6dc697a9bc35a31a882c1fb67f6467 /src/game_state.cpp
parent84d9333a4ac4b9d60dc9b525b8006456d6f614dc (diff)
Removed some buildings made network more efficient
Also decreased number of sensors.
Diffstat (limited to 'src/game_state.cpp')
-rw-r--r--src/game_state.cpp35
1 files changed, 11 insertions, 24 deletions
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<bool> GameState::toBitArray() const
{
- std::vector<bool> result(102);
+ std::vector<bool> 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<bool> 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<bool> 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;
}