From 5a245bd4f2cbac8aee4efe7220533f41d6418312 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 3 Jun 2012 03:40:04 +0200 Subject: GOB: Consume shields in Penetration --- engines/gob/minigames/geisha/penetration.cpp | 27 +++++++++++++++++++++++++++ engines/gob/minigames/geisha/penetration.h | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp index c8fbe31249..e4e7798216 100644 --- a/engines/gob/minigames/geisha/penetration.cpp +++ b/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::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() { diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h index 9109cb5c68..4d3455b638 100644 --- a/engines/gob/minigames/geisha/penetration.h +++ b/engines/gob/minigames/geisha/penetration.h @@ -54,6 +54,13 @@ private: 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 @@ private: uint8 _subTileX; uint8 _subTileY; + Common::List _shields; + + void init(); void deinit(); @@ -98,6 +108,8 @@ private: void moveSub(int x, int y, uint16 animation); bool isWalkable(byte tile) const; + + void checkShields(); }; } // End of namespace Geisha -- cgit v1.2.3