diff options
author | Sven Hesse | 2012-06-03 01:12:21 +0200 |
---|---|---|
committer | Sven Hesse | 2012-06-03 01:29:44 +0200 |
commit | 8dcb93f2ce04df49dea38f56bc97aef900a05122 (patch) | |
tree | 5f6adcc6219f9a9dbb429b557b9f91fd19f5556b /engines | |
parent | 43abb525d4004cb0816c8ea506b0b963d784ccf3 (diff) | |
download | scummvm-rg350-8dcb93f2ce04df49dea38f56bc97aef900a05122.tar.gz scummvm-rg350-8dcb93f2ce04df49dea38f56bc97aef900a05122.tar.bz2 scummvm-rg350-8dcb93f2ce04df49dea38f56bc97aef900a05122.zip |
GOB: Draw the Penetration map and do basic movement
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/minigames/geisha/penetration.cpp | 44 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/penetration.h | 10 |
2 files changed, 53 insertions, 1 deletions
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp index 77edebce48..41346a896f 100644 --- a/engines/gob/minigames/geisha/penetration.cpp +++ b/engines/gob/minigames/geisha/penetration.cpp @@ -170,7 +170,8 @@ const byte Penetration::kMaps[kModeCount][kFloorCount][kMapWidth * kMapHeight] = Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _sprites(0), _objects(0), - _shieldMeter(0), _healthMeter(0) { + _shieldMeter(0), _healthMeter(0), _floor(0), _mapUpdate(false), _mapX(0), _mapY(0), + _subTileX(0), _subTileY(0) { _background = new Surface(320, 200, 1); @@ -220,6 +221,9 @@ bool Penetration::play(bool hasAccessPass, bool hasMaxEnergy, bool testMode) { // Aborting the game if (key == kKeyEscape) break; + + // Handle the sub movement + handleSub(key); } deinit(); @@ -345,10 +349,18 @@ void Penetration::createMap() { case 57: // Start position _sprites->draw(*_map, 30, posX, posY); *mapTile = 0; + + _subTileX = x; + _subTileY = y; + + _mapX = _subTileX * kMapTileWidth; + _mapY = _subTileY * kMapTileHeight; break; } } } + + _mapUpdate = true; } void Penetration::initScreen() { @@ -377,6 +389,27 @@ int16 Penetration::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseB return _vm->_util->checkKey(); } +void Penetration::handleSub(int16 key) { + if (key == kKeyLeft) + moveSub(-5, 0); + else if (key == kKeyRight) + moveSub( 5, 0); + else if (key == kKeyUp) + moveSub( 0, -5); + else if (key == kKeyDown) + moveSub( 0, 5); +} + +void Penetration::moveSub(int x, int y) { + _mapX = CLIP<int16>(_mapX + x, 0, kMapWidth * kMapTileWidth); + _mapY = CLIP<int16>(_mapY + y, 0, kMapHeight * kMapTileHeight); + + _subTileX = _mapX / kMapTileWidth; + _subTileY = _mapY / kMapTileHeight; + + _mapUpdate = true; +} + void Penetration::updateAnims() { int16 left, top, right, bottom; @@ -388,6 +421,15 @@ void Penetration::updateAnims() { _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); } + if (_mapUpdate) { + _vm->_draw->_backSurface->blit(*_map, _mapX, _mapY, + _mapX + kPlayAreaWidth - 1, _mapY + kPlayAreaHeight - 1, kPlayAreaX, kPlayAreaY); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, kPlayAreaX, kPlayAreaY, + kPlayAreaX + kPlayAreaWidth - 1, kPlayAreaY + kPlayAreaHeight - 1); + } + + _mapUpdate = false; + // Draw the current animation frames for (Common::List<ANIObject *>::iterator a = _anims.begin(); a != _anims.end(); ++a) { diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h index 897b10940c..72201d21d8 100644 --- a/engines/gob/minigames/geisha/penetration.h +++ b/engines/gob/minigames/geisha/penetration.h @@ -74,6 +74,13 @@ private: Surface *_map; byte _mapTiles[kMapWidth * kMapHeight]; + bool _mapUpdate; + uint16 _mapX; + uint16 _mapY; + + uint8 _subTileX; + uint8 _subTileY; + void init(); void deinit(); @@ -84,6 +91,9 @@ private: void updateAnims(); int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); + + void handleSub(int16 key); + void moveSub(int x, int y); }; } // End of namespace Geisha |