1
/* ScummVM - Graphic Adventure Engine
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
#include "common/debug.h"
28
#include "toon/flux.h"
32
CharacterFlux::CharacterFlux(ToonEngine *vm) : Character(vm) {
34
_animationInstance = vm->getAnimationManager()->createNewInstance(kAnimationCharacter);
35
_animationInstance->setUseMask(true);
36
vm->getAnimationManager()->addInstance(_animationInstance);
39
CharacterFlux::~CharacterFlux() {
42
void CharacterFlux::playStandingAnim() {
43
debugC(4, kDebugCharacter, "playStandingAnim()");
45
_animationInstance->setAnimation(_walkAnim);
46
_animationInstance->setFrame(_facing * 3);
47
_animationInstance->setAnimationRange(_facing * 3, _facing * 3);
48
_animationInstance->stopAnimation();
49
_animationInstance->setLooping(true);
54
void CharacterFlux::setVisible(bool visible) {
55
if (_vm->state()->_currentChapter == 2) {
56
Character::setVisible(false);
58
Character::setVisible(visible);
62
void CharacterFlux::playWalkAnim(int32 start, int32 end) {
63
debugC(4, kDebugCharacter, "playWalkAnim(%d, %d)", start, end);
65
_animationInstance->setAnimation(_walkAnim);
66
_animationInstance->setAnimationRange(24 + _facing * 10, 24 + _facing * 10 + 9);
67
_animationInstance->playAnimation();
68
_animationInstance->setFps(16);
69
_animationInstance->setLooping(true);
72
int32 CharacterFlux::fixFacingForAnimation(int32 originalFacing, int32 animationId) {
74
static const byte fixFluxAnimationFacing[] = {
75
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
76
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xee, 0xff, 0xff, 0xff,
77
0xff, 0xff, 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x55,
78
0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
80
byte animFacingFlag = fixFluxAnimationFacing[animationId];
81
int32 v5 = 1 << originalFacing;
82
int32 v6 = 1 << originalFacing;
85
if (v6 & animFacingFlag) {
87
} else if (v5 & animFacingFlag) {
95
int32 finalFacing = 0;
96
for (finalFacing = 0; ; ++finalFacing) {
105
void CharacterFlux::setPosition(int32 x, int32 y) {
106
debugC(5, kDebugCharacter, "setPosition(%d, %d)", x, y);
108
_z = _vm->getLayerAtPoint(x, y);
109
_scale = _vm->getScaleAtPoint(x, y);
110
int32 width = _walkAnim->getWidth() * _scale / 1024;
111
int32 height = 165 * _scale / 1024;
112
_animationInstance->setPosition(x - width / 2, y - height, _z , false);
113
_animationInstance->setScale(_scale);
115
// in original code, flux shadow scale is 3/4 of real scale
116
int32 shadowScale = _scale * 3 / 4;
118
// work out position and scale of the shadow below character
119
int32 shadowWidth = _shadowAnim->getWidth() * shadowScale / 1024;
120
int32 shadowHeight = _shadowAnim->getHeight() * shadowScale / 1024;
121
_shadowAnimationInstance->setPosition(x - shadowWidth / 2, y - shadowHeight / 2 , _z , false);
122
_shadowAnimationInstance->setScale(shadowScale);
127
_animationInstance->setLayerZ(_y);
130
void CharacterFlux::update(int32 timeIncrement) {
131
debugC(5, kDebugCharacter, "update(%d)", timeIncrement);
132
Character::update(timeIncrement);
136
int32 CharacterFlux::getRandomIdleAnim() {
137
debugC(3, kDebugCharacter, "getRandomIdleAnim()");
138
static const int32 idle[] = { 0xe, 0xf, 0x21, 0x22, 0x24, 0x25, 0x27 };
139
return idle[_vm->randRange(0, 6)];
142
} // End of namespace Toon