changeset 245:ed1565a5a2a0

Fixed second camera in rio. Now multiple Camera.setLocation calls per frame are handled correctly.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 25 Mar 2009 14:17:59 +0000
parents 7887f3854862
children 8156de05a544
files clients/rio_de_hola/scripts/world.py engine/core/view/camera.cpp engine/core/view/camera.h
diffstat 3 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/clients/rio_de_hola/scripts/world.py	Wed Mar 25 09:38:10 2009 +0000
+++ b/clients/rio_de_hola/scripts/world.py	Wed Mar 25 14:17:59 2009 +0000
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import fife, math, random
 import pychan
 import pychan.widgets as widgets
@@ -145,8 +146,8 @@
 		self.initial_cam2_x = self.cameras['small'].getLocation().getExactLayerCoordinates().x
 		self.cur_cam2_x = self.initial_cam2_x
 		self.cam2_scrolling_right = True
-		self.cameras['small'].setEnabled(False)
-
+		# We need to set the second cameras location
+		self.cameras['small'].setLocation(self.hero.agent.getLocation())
 		self.target_rotation = self.cameras['main'].getRotation()
 
 	def save(self, filename):
--- a/engine/core/view/camera.cpp	Wed Mar 25 09:38:10 2009 +0000
+++ b/engine/core/view/camera.cpp	Wed Mar 25 14:17:59 2009 +0000
@@ -145,7 +145,7 @@
 		if ((m_prev_origo == m_cur_origo) && (m_prev_origo == ScreenPoint(0,0,0))) {
 			m_cur_origo = toScreenCoordinates(ExactModelCoordinate(0,0,0));
 			m_prev_origo = m_cur_origo;
-		}	
+		}
 		m_location = location;
 		
 		CellGrid* cg = NULL;
@@ -160,7 +160,6 @@
 		
 		updateMatrices();
 		
-		m_prev_origo = m_cur_origo;
 		m_cur_origo = toScreenCoordinates(ExactModelCoordinate(0,0,0));
 	}
 
@@ -473,7 +472,7 @@
 	}
 
 	void Camera::render() {
-		ScreenPoint cammove = getLatestMovement();
+		ScreenPoint cammove = m_prev_origo - m_cur_origo;
 		
 		Map* map = m_location.getMap();
 		if (!map) {
--- a/engine/core/view/camera.h	Wed Mar 25 09:38:10 2009 +0000
+++ b/engine/core/view/camera.h	Wed Mar 25 14:17:59 2009 +0000
@@ -253,12 +253,6 @@
 		 */
 		void refresh();
 
-		/** Returns latest camera movement in screen coordinates (dx, dy)
-		 */
-		inline ScreenPoint getLatestMovement() {
-			return m_prev_origo - m_cur_origo;
-		}
-		
 		/** Resets temporary values from last update round, like warped flag
 		 */
 		void resetUpdates();