Skip to content
Browse files

GOB: Consume shields in Penetration

  • Loading branch information...
1 parent 627e870 commit 5a245bd4f2cbac8aee4efe7220533f41d6418312 @DrMcCoy DrMcCoy committed Jun 3, 2012
Showing with 39 additions and 0 deletions.
  1. +27 −0 engines/gob/minigames/geisha/penetration.cpp
  2. +12 −0 engines/gob/minigames/geisha/penetration.h
View
27 engines/gob/minigames/geisha/penetration.cpp
@@ -193,6 +193,10 @@ const byte Penetration::kMaps[kModeCount][kFloorCount][kMapWidth * kMapHeight] =
};
+Penetration::Position::Position(uint16 pX, uint16 pY) : x(pX), y(pY) {
+}
+
+
Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _sprites(0), _objects(0), _sub(0),
_shieldMeter(0), _healthMeter(0), _floor(0), _mapUpdate(false), _mapX(0), _mapY(0),
_subTileX(0), _subTileY(0) {
@@ -303,6 +307,8 @@ void Penetration::createMap() {
// Copy the correct map
memcpy(_mapTiles, kMaps[_testMode ? 1 : 0][_floor], kMapWidth * kMapHeight);
+ _shields.clear();
+
_map->fill(kColorBlack);
// Draw the map tiles
@@ -378,6 +384,8 @@ void Penetration::createMap() {
_map->fillRect(posX + 4, posY + 8, posX + 7, posY + 18, kColorFloor); // Area left to shield
_map->fillRect(posX + 17, posY + 8, posX + 20, posY + 18, kColorFloor); // Area right to shield
+
+ _shields.push_back(Position(x, y));
break;
case 57: // Start position
@@ -473,6 +481,25 @@ void Penetration::moveSub(int x, int y, uint16 animation) {
if (_sub->getAnimation() != animation)
_sub->setAnimation(animation);
+
+ checkShields();
+}
+
+void Penetration::checkShields() {
+ for (Common::List<Position>::iterator pos = _shields.begin(); pos != _shields.end(); ++pos) {
+ if ((pos->x == _subTileX) && (pos->y == _subTileY)) {
+ // Charge shields
+ _shieldMeter->setMaxValue();
+
+ // Erase the shield from the map
+ const int mapX = kPlayAreaBorderWidth + pos->x * kMapTileWidth;
+ const int mapY = kPlayAreaBorderHeight + pos->y * kMapTileHeight;
+ _sprites->draw(*_map, 30, mapX, mapY);
+
+ _shields.erase(pos);
+ break;
+ }
+ }
}
void Penetration::updateAnims() {
View
12 engines/gob/minigames/geisha/penetration.h
@@ -54,6 +54,13 @@ class Penetration {
static const byte kMaps[kModeCount][kFloorCount][kMapWidth * kMapHeight];
+ struct Position {
+ uint16 x;
+ uint16 y;
+
+ Position(uint16 pX, uint16 pY);
+ };
+
GobEngine *_vm;
bool _hasAccessPass;
@@ -83,6 +90,9 @@ class Penetration {
uint8 _subTileX;
uint8 _subTileY;
+ Common::List<Position> _shields;
+
+
void init();
void deinit();
@@ -98,6 +108,8 @@ class Penetration {
void moveSub(int x, int y, uint16 animation);
bool isWalkable(byte tile) const;
+
+ void checkShields();
};
} // End of namespace Geisha

0 comments on commit 5a245bd

Please sign in to comment.
Something went wrong with that request. Please try again.