diff options
author | Sven Hesse | 2012-07-08 00:20:36 +0200 |
---|---|---|
committer | Sven Hesse | 2012-07-30 01:44:45 +0200 |
commit | 6533047514d0ab1cc7273a0c071fa24b6c2f7b71 (patch) | |
tree | 89821b7bfeba7e45b3f30d7dbc104ea8b9bb087e /engines | |
parent | 20a96733a5f982e427a9143ded14e2af418ac6df (diff) | |
download | scummvm-rg350-6533047514d0ab1cc7273a0c071fa24b6c2f7b71.tar.gz scummvm-rg350-6533047514d0ab1cc7273a0c071fa24b6c2f7b71.tar.bz2 scummvm-rg350-6533047514d0ab1cc7273a0c071fa24b6c2f7b71.zip |
GOB: Add the walking child in the character generator
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/module.mk | 1 | ||||
-rw-r--r-- | engines/gob/pregob/onceupon/chargenchild.cpp | 104 | ||||
-rw-r--r-- | engines/gob/pregob/onceupon/chargenchild.h | 51 | ||||
-rw-r--r-- | engines/gob/pregob/onceupon/onceupon.cpp | 22 |
4 files changed, 176 insertions, 2 deletions
diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 15351848de..4858e97c60 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -85,6 +85,7 @@ MODULE_OBJS := \ pregob/onceupon/abracadabra.o \ pregob/onceupon/babayaga.o \ pregob/onceupon/stork.o \ + pregob/onceupon/chargenchild.o \ minigames/geisha/evilfish.o \ minigames/geisha/oko.o \ minigames/geisha/meter.o \ diff --git a/engines/gob/pregob/onceupon/chargenchild.cpp b/engines/gob/pregob/onceupon/chargenchild.cpp new file mode 100644 index 0000000000..7150c69b5f --- /dev/null +++ b/engines/gob/pregob/onceupon/chargenchild.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gob/surface.h" +#include "gob/anifile.h" + +#include "gob/pregob/onceupon/chargenchild.h" + +enum Animation { + kAnimWalkLeft = 0, + kAnimWalkRight = 1, + kAnimJumpLeft = 2, + kAnimJumpRight = 3, + kAnimTapFoot = 14 +}; + +namespace Gob { + +namespace OnceUpon { + +CharGenChild::CharGenChild(const ANIFile &ani) : ANIObject(ani) { + setPosition(265, 110); + setAnimation(kAnimWalkLeft); + setVisible(true); + setPause(false); +} + +CharGenChild::~CharGenChild() { +} + +void CharGenChild::advance() { + bool wasLastFrame = lastFrame(); + + ANIObject::advance(); + + int16 x, y, left, top, width, height; + getPosition(x, y); + getFramePosition(left, top); + getFrameSize(width, height); + + const int16 right = left + width - 1; + + switch (getAnimation()) { + case kAnimWalkLeft: + if (left <= 147) + setAnimation(kAnimWalkRight); + break; + + case kAnimWalkRight: + if (right >= 290) { + setAnimation(kAnimJumpLeft); + + setPosition(x, y - 14); + } + break; + + case kAnimJumpLeft: + if (wasLastFrame) { + setAnimation(kAnimTapFoot); + + setPosition(x, y - 10); + } + break; + + case kAnimTapFoot: + if (wasLastFrame) { + setAnimation(kAnimJumpRight); + + setPosition(x, y + 10); + } + break; + + case kAnimJumpRight: + if (wasLastFrame) { + setAnimation(kAnimWalkLeft); + + setPosition(x, y + 14); + } + break; + } +} + +} // End of namespace OnceUpon + +} // End of namespace Gob diff --git a/engines/gob/pregob/onceupon/chargenchild.h b/engines/gob/pregob/onceupon/chargenchild.h new file mode 100644 index 0000000000..afbe3fd2fe --- /dev/null +++ b/engines/gob/pregob/onceupon/chargenchild.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GOB_PREGOB_ONCEUPON_CHARGENCHILD_H +#define GOB_PREGOB_ONCEUPON_CHARGENCHILD_H + +#include "common/system.h" + +#include "gob/aniobject.h" + +namespace Gob { + +class Surface; +class ANIFile; + +namespace OnceUpon { + +/** The child running around on the character generator screen. */ +class CharGenChild : public ANIObject { +public: + CharGenChild(const ANIFile &ani); + ~CharGenChild(); + + /** Advance the animation to the next frame. */ + void advance(); +}; + +} // End of namespace OnceUpon + +} // End of namespace Gob + +#endif // GOB_PREGOB_ONCEUPON_CHARGENCHILD_H diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index 53fa3bcece..7eef740139 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -37,6 +37,7 @@ #include "gob/pregob/onceupon/onceupon.h" #include "gob/pregob/onceupon/palettes.h" +#include "gob/pregob/onceupon/chargenchild.h" static const uint kLanguageCount = 5; @@ -1646,6 +1647,15 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { CharGenState state = kCharGenStateHead; charGenSetup(state); + ANIFile ani(_vm, "ba.ani", 320); + ANIList anims; + + anims.push_back(new CharGenChild(ani)); + + ani.recolor(0x0F, 0x0C); + ani.recolor(0x0E, 0x0A); + ani.recolor(0x08, 0x09); + fadeOut(); _vm->_draw->forceBlit(); @@ -1665,7 +1675,7 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { break; } - // clearAnim(anims); + clearAnim(anims); if (state == kCharGenStateStoryName) { if ((mouseButtons != kMouseButtonsNone) || (key != 0)) { @@ -1727,6 +1737,8 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { if ((state == kCharGenStateTrousers) && (trousers >= 0)) { _colorTrousers = trousers; + ani.recolor(0x09, _colorTrousers); + state = kCharGenStateName; charGenSetup(state); _vm->_draw->forceBlit(); @@ -1736,6 +1748,8 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { if ((state == kCharGenStateJacket) && (jacket >= 0)) { _colorJacket = jacket; + ani.recolor(0x0A, _colorJacket); + state = kCharGenStateTrousers; charGenSetup(state); _vm->_draw->forceBlit(); @@ -1745,6 +1759,8 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { if ((state == kCharGenStateHair) && (hair >= 0)) { _colorHair = hair; + ani.recolor(0x0C, _colorHair); + state = kCharGenStateJacket; charGenSetup(state); _vm->_draw->forceBlit(); @@ -1760,7 +1776,7 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { } } - //drawAnim(anims); + drawAnim(anims); showCursor(); fadeIn(); @@ -1770,6 +1786,8 @@ OnceUpon::CharGenAction OnceUpon::characterGenerator() { fadeOut(); hideCursor(); + freeAnims(anims); + if (_vm->shouldQuit()) return kCharGenAbort; |