ScummVM API documentation
animation.h
1 /* ScummVM - Graphic Adventure Engine
2  *
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.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
24  * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
25  */
26 
27 /* Original name: TRIP5 / Trippancy V - the sprite animation subsystem */
28 
29 #ifndef AVALANCHE_ANIMATION_H
30 #define AVALANCHE_ANIMATION_H
31 
32 namespace Avalanche {
33 class AvalancheEngine;
34 class Animation;
35 
36 enum Direction {
37  kDirUp = 0, kDirRight, kDirDown, kDirLeft,
38  kDirUpRight, kDirDownRight, kDirDownLeft, kDirUpLeft,
39  kDirStopped, kDirNone = 177
40 };
41 
43 public:
44  byte _id;
45 
46  byte _xLength, _yLength;
47  ManiType *_mani[24];
48  SilType *_sil[24];
49  byte _frameNum; // Number of pictures.
50  byte _seq; // How many in one stride.
51  byte _characterId; // The number according to Acci. (1=Avvy, etc.)
52  byte _count; // Counts before changing step.
53 
54  Direction _facingDir;
55  byte _stepNum;
56  int16 _x, _y; // Current xy coords.
57  int8 _moveX, _moveY; // Amount to move sprite by, each step.
58  bool _quick, _visible, _homing, _doCheck;
59  int16 _homingX, _homingY; // Homing x & y coords.
60  byte _speedX, _speedY;
61  bool _vanishIfStill;
62  bool _callEachStepFl;
63  byte _eachStepProc;
64 
65  AnimationType(Animation *anim);
66 
67  void init(byte spritenum, bool doCheck);
68  void reset();
69  void draw();
70  void turn(Direction whichway);
71  void appear(int16 wx, int16 wy, Direction wf);
72  void bounce();
73  void walk();
74  void walkTo(byte pednum);
75  void stopHoming();
76  void setSpeed(int8 xx, int8 yy);
77  void stopWalk();
78  void chatter();
79  void remove();
80 
81 private:
82  Animation *_anim;
83 
84  int16 _oldX[2], _oldY[2]; // Last xy coords.
85  Color _fgBubbleCol, _bgBubbleCol; // Foreground & background bubble colors.
86 
87  bool checkCollision();
88  int8 getSign(int16 val);
89  void homeStep();
90 };
91 
92 class Animation {
93 public:
94  friend class AnimationType;
95 
96  static const byte kSpriteNumbMax = 5; // current max no. of sprites
97 
98  enum Proc {
99  kProcNone = 0,
100  kProcFollowAvvyY,
101  kProcBackAndForth,
102  kProcFaceAvvy,
103  kProcArrow,
104  kProcGrabAvvy,
105  kProcFollowAvvy
106  };
107 
108  AnimationType *_sprites[kSpriteNumbMax];
109 
111  ~Animation();
112 
113  void animLink();
114  void resetAnims();
115  void callSpecial(uint16 which);
116  void catacombMove(byte ped);
117  void stopWalking();
118  void setMoveSpeed(byte t, Direction dir);
119  void appearPed(byte sprNum, byte pedNum);
120  bool inField(byte which);
121  bool nearDoor();
122  void updateSpeed();
123  void handleMoveKey(const Common::Event &event);
124  void hideInCupboard();
125 
126  // These 2 functions are responsible for playing the thunder animation when the player swears too much.
127  void drawLightning(int16 x1, int16 y1, int16 x2, int16 y2);
128  void thunder();
129 
130  void wobble();
131 
132  void setDirection(Direction dir);
133  void setOldDirection(Direction dir);
134  Direction getDirection();
135  Direction getOldDirection();
136 
137  void setAvvyClothes(int id);
138  int getAvvyClothes();
139 
140  void resetVariables();
141  void synchronize(Common::Serializer &sz);
142 private:
143  Direction _direction; // The direction Avvy is currently facing.
144  Direction _oldDirection;
145  static const int32 kCatacombMap[8][8];
146  bool _arrowTriggered; // And has the arrow been triggered?
147  bool _mustExclaim;
148  byte _geidaSpin, _geidaTime; // For the making "Geida dizzy" joke.
149  uint16 _sayWhat;
150 
151  AvalancheEngine *_vm;
152 
153  byte checkFeet(int16 x1, int16 x2, int16 oy, int16 y, byte yl);
154  byte geidaPed(byte ped);
155  void dawnDelay();
156 
157  void grabAvvy(byte tripnum);
158  void arrowProcs(byte tripnum);
159 
160  // Different movements for NPCs:
161  void followAvalotY(byte tripnum);
162  void backAndForth(byte tripnum);
163  void faceAvvy(byte tripnum);
164 
165  // Movements for Homing NPCs: Spludwick and Geida.
166  void spin(Direction dir, byte &tripnum);
167  void takeAStep(byte &tripnum);
168  void follow(byte tripnum);
169 
170  void drawSprites();
171 };
172 
173 } // End of namespace Avalanche.
174 
175 #endif // AVALANCHE_ANIMATION_H
Definition: animation.h:32
Definition: animation.h:42
Definition: avalanche.h:74
Definition: serializer.h:79
Definition: events.h:198
Definition: animation.h:92