[Scummvm-cvs-logs] SF.net SVN: scummvm:[45718] scummvm/trunk/engines/teenagent

megath at users.sourceforge.net megath at users.sourceforge.net
Sat Nov 7 10:19:50 CET 2009


Revision: 45718
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45718&view=rev
Author:   megath
Date:     2009-11-07 09:19:49 +0000 (Sat, 07 Nov 2009)

Log Message:
-----------
improved walking code

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/scene.cpp
    scummvm/trunk/engines/teenagent/scene.h
    scummvm/trunk/engines/teenagent/teenagent.cpp

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-07 09:18:30 UTC (rev 45717)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-07 09:19:49 UTC (rev 45718)
@@ -41,9 +41,7 @@
 
 void Scene::warp(const Common::Point &_point, byte o) {
 	Common::Point point(_point);
-	destination = position = position0 = point;
-	progress = 0;
-	progress_total = 1;
+	destination = position = point;
 	if (o)
 		orientation = o;
 }
@@ -57,6 +55,7 @@
 			const Walkbox &w = scene_walkboxes[i];
 			if (w.rect.in(point)) {
 				debug(0, "bumped into walkbox %u", i);
+				w.dump();
 				byte o = w.orientation;
 				switch (o) {
 				case 1:
@@ -85,9 +84,6 @@
 	}
 	destination = point;
 	orientation = orient;
-	position0 = position;
-	progress_total = 1 + (int)(0.5f + sqrt((float)position.sqrDist(destination)) / 10);
-	progress = 0;
 }
 
 
@@ -308,21 +304,29 @@
 		}
 		return false;
 
-	case Common::EVENT_KEYUP:
-		if (intro && event.kbd.keycode == Common::KEYCODE_ESCAPE) {
-			intro = false;
-			message.clear();
-			events.clear();
-			sounds.clear();
-			current_event.clear();
-			message_color = 0xd1;
-			Resources::instance()->font7.color = 0xd1;
-			for (int i = 0; i < 4; ++i)
-				custom_animation[i].free();
-			_engine->playMusic(4);
-			init(10, Common::Point(136, 153));
+	case Common::EVENT_KEYDOWN:
+		if (event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_SPACE) {
+			if (intro) {
+				intro = false;
+				message.clear();
+				events.clear();
+				sounds.clear();
+				current_event.clear();
+				message_color = 0xd1;
+				Resources::instance()->font7.color = 0xd1;
+				for (int i = 0; i < 4; ++i) 
+					custom_animation[i].free();
+				_engine->playMusic(4);
+				init(10, Common::Point(136, 153));
+				return true;
+			}
+		
+			if (!message.empty()) {
+				message.clear();
+				nextEvent();
+				return true;
+			}
 		}
-		return true;
 
 	default:
 		return false;
@@ -414,19 +418,31 @@
 			} else if (!hide_actor) {
 				actor_animation.free();
 
-				if (progress < progress_total) {
-					Common::Point dp(destination.x - position0.x, destination.y - position0.y);
+				if (position != destination) {
+					const int speed_x = 10, speed_y = 5;
+					Common::Point dp(destination.x - position.x, destination.y - position.y);
+					switch(orientation) {
+					case 2: //left or right
+					case 4: 
+						if (dp.y != 0)
+							dp.x = 0; //first, walking up-down
+						break;
+					default:
+						if (dp.x != 0)
+							dp.y = 0; //first, walking left-right
+					}
+					
 					int o;
 					if (ABS(dp.x) > ABS(dp.y))
 						o = dp.x > 0 ? Object::kActorRight : Object::kActorLeft;
 					else
 						o = dp.y > 0 ? Object::kActorDown : Object::kActorUp;
 
-					position.x = position0.x + dp.x * progress / progress_total;
-					position.y = position0.y + dp.y * progress / progress_total;
+					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);
-					++progress;
-					if (progress >= progress_total) {
+					if (position == destination) {
 						position = destination;
 						if (orientation == 0)
 							orientation = o; //save last orientation

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2009-11-07 09:18:30 UTC (rev 45717)
+++ scummvm/trunk/engines/teenagent/scene.h	2009-11-07 09:19:49 UTC (rev 45718)
@@ -161,8 +161,7 @@
 	Common::Rect actor_animation_position, animation_position[4];
 
 	Actor teenagent, teenagent_idle;
-	Common::Point position0, position, destination;
-	int progress, progress_total;
+	Common::Point position, destination;
 	uint8 orientation;
 
 	Common::Array<Common::Array<Object> > objects;

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-07 09:18:30 UTC (rev 45717)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-07 09:19:49 UTC (rev 45718)
@@ -66,8 +66,10 @@
 			for (uint i = 0; i < hotspots.size(); ++i) {
 				const UseHotspot &spot = hotspots[i];
 				if (spot.inventory_id == inv->id && dst_object->id == spot.object_id) {
-					debug(0, "combine! pos?: %u,%u", spot.x, spot.y);
-					//moveTo(Common::Point(obj->x, obj->y), NULL, Examine);
+					debug(0, "use object on hotspot!");
+					spot.dump();
+					if (spot.actor_x != 0xffff && spot.actor_y != 0xffff)
+						moveTo(spot.actor_x, spot.actor_y, spot.orientation);
 					inventory->resetSelectedObject();
 					if (!processCallback(TO_LE_16(spot.callback)))
 						debug(0, "fixme! display proper description");
@@ -419,6 +421,10 @@
 	SceneEvent event(SceneEvent::kWalk);
 	event.dst.x = x;
 	event.dst.y = y;
+	if (o > 4) {
+		warning("invalid orientation %d", o);
+		o = 0;
+	}
 	event.orientation = o;
 	event.color = warp ? 1 : 0;
 	scene->push(event);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list