aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-15 10:15:39 +0000
committerVladimir Menshakov2009-11-15 10:15:39 +0000
commit73a8d06cf46cdddb8bef87ee8bb01d9a5bb5854b (patch)
tree6728321b3b3bbb703a7f413219bf2978e88c5ca4
parented81c0c35dd652c54bab4b345ec647d9d5b99635 (diff)
downloadscummvm-rg350-73a8d06cf46cdddb8bef87ee8bb01d9a5bb5854b.tar.gz
scummvm-rg350-73a8d06cf46cdddb8bef87ee8bb01d9a5bb5854b.tar.bz2
scummvm-rg350-73a8d06cf46cdddb8bef87ee8bb01d9a5bb5854b.zip
added face animation.
svn-id: r45914
-rw-r--r--engines/teenagent/actor.cpp43
-rw-r--r--engines/teenagent/actor.h4
-rw-r--r--engines/teenagent/scene.cpp4
3 files changed, 45 insertions, 6 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp
index bedb3ce55c..eac02ca1e8 100644
--- a/engines/teenagent/actor.cpp
+++ b/engines/teenagent/actor.cpp
@@ -27,12 +27,20 @@
namespace TeenAgent {
-Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame) {
+Actor::Actor() : head_index(0) {}
+
+//idle animation lists at dseg: 0x6540
+
+Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool render_head) {
const uint8 frames_left_right[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const uint8 frames_up[] = {18, 19, 20, 21, 22, 23, 24, 25, };
const uint8 frames_down[] = {10, 11, 12, 13, 14, 15, 16, 17, };
- Surface *s = NULL;
+ const uint8 frames_head_left_right[] = {39, 26, 27, 28, 29, 30, 31, };
+ const uint8 frames_head_up[] = { 41, 37, 38, };
+ const uint8 frames_head_down[] = {40, 32, 33, 34, 35, 36};
+
+ Surface *s = NULL, *head = NULL;
if (delta_frame == 0) {
index = 0; //static animation
@@ -41,6 +49,13 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
switch (orientation) {
case Object::kActorLeft:
case Object::kActorRight:
+ if (render_head) {
+ if (head_index >= sizeof(frames_head_left_right))
+ head_index = 0;
+ head = frames + frames_head_left_right[head_index];
+ ++head_index;
+ }
+
if (index >= sizeof(frames_left_right))
index = 1;
s = frames + frames_left_right[index];
@@ -48,6 +63,13 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
dy = 62;
break;
case Object::kActorUp:
+ if (render_head) {
+ if (head_index >= sizeof(frames_head_up))
+ head_index = 0;
+ head = frames + frames_head_up[head_index];
+ ++head_index;
+ }
+
if (index >= sizeof(frames_up))
index = 1;
s = frames + frames_up[index];
@@ -55,6 +77,13 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
dy = 62;
break;
case Object::kActorDown:
+ if (render_head) {
+ if (head_index >= sizeof(frames_head_down))
+ head_index = 0;
+ head = frames + frames_head_down[head_index];
+ ++head_index;
+ }
+
if (index >= sizeof(frames_down))
index = 1;
s = frames + frames_down[index];
@@ -77,7 +106,15 @@ Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &posi
if (yp + s->h > 200)
yp = 200 - s->h;
- return s != NULL? s->render(surface, xp, yp, orientation == Object::kActorLeft): Common::Rect();
+ Common::Rect dirty;
+
+ if (s)
+ dirty = s->render(surface, xp, yp, orientation == Object::kActorLeft);
+
+ if (head)
+ dirty.extend(head->render(surface, xp, yp, orientation == Object::kActorLeft));
+
+ return dirty;
}
} // End of namespace TeenAgent
diff --git a/engines/teenagent/actor.h b/engines/teenagent/actor.h
index 693ca7a2ee..9ae213d7f8 100644
--- a/engines/teenagent/actor.h
+++ b/engines/teenagent/actor.h
@@ -28,8 +28,10 @@
namespace TeenAgent {
class Actor : public Animation {
+ uint head_index;
public:
- Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame);
+ Actor();
+ Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head);
};
} // End of namespace TeenAgent
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 3e5ade2c27..0da2b5014f 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -654,7 +654,7 @@ bool Scene::render(OSystem *system) {
position.x += (ABS(dp.x) < speed_x? dp.x: SIGN(dp.x) * speed_x);
position.y += (ABS(dp.y) < speed_y? dp.y: SIGN(dp.y) * speed_y);
- actor_animation_position = teenagent.render(surface, position, o, 1);
+ actor_animation_position = teenagent.render(surface, position, o, 1, false);
if (position == destination) {
path.pop_front();
if (path.empty()) {
@@ -668,7 +668,7 @@ bool Scene::render(OSystem *system) {
} else
busy = true;
} else
- actor_animation_position = teenagent.render(surface, position, orientation, 0);
+ actor_animation_position = teenagent.render(surface, position, orientation, 0, false);
}
}