diff options
author | Sven Hesse | 2012-06-02 22:12:25 +0200 |
---|---|---|
committer | Sven Hesse | 2012-06-02 23:14:12 +0200 |
commit | 585ceb566f27880ae7ea426efc70192b03a26d8d (patch) | |
tree | a2d6b9a1061d1bf63a6bc8f9d64a19a8d3479b40 /engines/gob/minigames | |
parent | 3eeb3d74163f2682bc27968df5e5e389174cdc1e (diff) | |
download | scummvm-rg350-585ceb566f27880ae7ea426efc70192b03a26d8d.tar.gz scummvm-rg350-585ceb566f27880ae7ea426efc70192b03a26d8d.tar.bz2 scummvm-rg350-585ceb566f27880ae7ea426efc70192b03a26d8d.zip |
GOB: Add animation handling frame to Penetration
Diffstat (limited to 'engines/gob/minigames')
-rw-r--r-- | engines/gob/minigames/geisha/penetration.cpp | 60 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/penetration.h | 9 |
2 files changed, 65 insertions, 4 deletions
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp index 153f2a6766..1bdc574aa3 100644 --- a/engines/gob/minigames/geisha/penetration.cpp +++ b/engines/gob/minigames/geisha/penetration.cpp @@ -25,7 +25,9 @@ #include "gob/draw.h" #include "gob/video.h" #include "gob/decfile.h" +#include "gob/cmpfile.h" #include "gob/anifile.h" +#include "gob/aniobject.h" #include "gob/minigames/geisha/penetration.h" @@ -52,7 +54,7 @@ static const byte kPalette[48] = { 0x15, 0x3F, 0x15 }; -Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _objects(0) { +Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _sprites(0), _objects(0) { _background = new Surface(320, 200, 1); } @@ -68,11 +70,28 @@ bool Penetration::play(bool hasAccessPass, bool hasMaxEnergy, bool testMode) { _vm->_draw->blitInvalidated(); _vm->_video->retrace(); - while (!_vm->_util->keyPressed() && !_vm->shouldQuit()) - _vm->_util->longDelay(1); + + while (!_vm->shouldQuit()) { + updateAnims(); + + // Draw and wait for the end of the frame + _vm->_draw->blitInvalidated(); + _vm->_util->waitEndFrame(); + + // Handle input + _vm->_util->processInput(); + + int16 mouseX, mouseY; + MouseButtons mouseButtons; + + int16 key = checkInput(mouseX, mouseY, mouseButtons); + // Aborting the game + if (key == kKeyEscape) + break; + } deinit(); - return true; + return false; } void Penetration::init() { @@ -80,13 +99,18 @@ void Penetration::init() { _vm->_video->drawPackedSprite("hyprmef2.cmp", *_background); + _sprites = new CMPFile(_vm, "tcifplai.cmp", 320, 200); _objects = new ANIFile(_vm, "tcite.ani", 320); } void Penetration::deinit() { + _anims.clear(); + delete _objects; + delete _sprites; _objects = 0; + _sprites = 0; } void Penetration::initScreen() { @@ -101,6 +125,34 @@ void Penetration::initScreen() { _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199); } +int16 Penetration::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) { + _vm->_util->getMouseState(&mouseX, &mouseY, &mouseButtons); + + return _vm->_util->checkKey(); +} + +void Penetration::updateAnims() { + int16 left, top, right, bottom; + + // Clear the previous animation frames + for (Common::List<ANIObject *>::iterator a = _anims.reverse_begin(); + a != _anims.end(); --a) { + + (*a)->clear(*_vm->_draw->_backSurface, left, top, right, bottom); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + } + + // Draw the current animation frames + for (Common::List<ANIObject *>::iterator a = _anims.begin(); + a != _anims.end(); ++a) { + + (*a)->draw(*_vm->_draw->_backSurface, left, top, right, bottom); + _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom); + + (*a)->advance(); + } +} + } // End of namespace Geisha } // End of namespace Gob diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h index 3f9aac7963..9bf87503f0 100644 --- a/engines/gob/minigames/geisha/penetration.h +++ b/engines/gob/minigames/geisha/penetration.h @@ -24,11 +24,13 @@ #define GOB_MINIGAMES_GEISHA_PENETRATION_H #include "common/system.h" +#include "common/list.h" namespace Gob { class GobEngine; class Surface; +class CMPFile; class ANIFile; namespace Geisha { @@ -45,13 +47,20 @@ private: GobEngine *_vm; Surface *_background; + CMPFile *_sprites; ANIFile *_objects; + Common::List<ANIObject *> _anims; + void init(); void deinit(); void initScreen(); + + void updateAnims(); + + int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); }; } // End of namespace Geisha |