Commits

Anonymous committed 2176e0f

Touch.prevX and Touch.prevY

Comments (0)

Files changed (3)

code/common/common.h

 	int x;
 	int y;
 
+	// previous position of this touch
+	int prevX;
+	int prevY;
+
 	// beginning position of this touch
 	int beginX;
 	int beginY;

code/payload/Lobster.cpp

 	virtual void touchMove(const Touch& touch)
 	{
 		dx =  2.0f * (touch.x - touch.beginX) / Configuration::screenWidth();
-		dy = -2.0f * (touch.y - touch.beginY) / Configuration::screenHeight();
+		dy = -3.0f * (touch.y - touch.beginY) / Configuration::screenHeight();
+
+		this->sprite1->position.x += 2.0f * (touch.x - touch.prevX) / Configuration::screenWidth();
+		this->sprite1->position.y -= 3.0f * (touch.y - touch.prevY) / Configuration::screenHeight();
 	}
 
 	virtual void touchEnd(const Touch& touch)

code/windows/main.cpp

 		convertToScreenSpace(x, y);
 
 		this->touch.id = this->touchCounter++;
-		this->touch.beginX = this->touch.x = x;
-		this->touch.beginY = this->touch.y = y;
+		this->touch.beginX = this->touch.prevX = this->touch.x = x;
+		this->touch.beginY = this->touch.prevY = this->touch.y = y;
 
 		application->touchBegin(touch);
 	}
 	{
 		convertToScreenSpace(x, y);
 
+		this->touch.prevX = this->touch.x;
+		this->touch.prevY = this->touch.y;
+
 		this->touch.x = x;
 		this->touch.y = y;
 
+		printf("x: %3d y: %3d prevX: %3d prevY: %3d beginX: %3d beginY: %3d\n", touch.x, touch.y, touch.prevX, touch.prevY, touch.beginX, touch.beginY);
+
 		if (this->touch.id != -1)
 			application->touchMove(touch);
 	}
 	{
 		convertToScreenSpace(x, y);
 
+		this->touch.prevX = this->touch.x;
+		this->touch.prevY = this->touch.y;
+
 		this->touch.x = x;
 		this->touch.y = y;