[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kolf
From:       Stefan Majewsky <majewsky () gmx ! net>
Date:       2010-10-31 23:23:41
Message-ID: 20101031232341.AD1F9AC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1191718 by majewsky:

Introduce (temporarily!) a preprocessor macro that switches ball movement between the available physics engines.

Box2D is not yet the default because its stepping causes some severe
regressions (i.e. ghost walls from which the ball bounces off).

 M  +10 -0     ball.cpp  
 M  +6 -0      ball.h  


--- trunk/KDE/kdegames/kolf/ball.cpp #1191717:1191718
@@ -105,10 +105,20 @@
 		game->ballMoved();
 }
 
+#if BALL_BOX2D_STEPPING
+void Ball::setVelocity(const Vector& velocity)
+{
+	CanvasItem::setPhysicalVelocity(velocity);
+	kDebug() << velocity;
+}
+#endif
+
 void Ball::doAdvance()
 {
+#if BALL_BOX2D_STEPPING == 0
 	if (!velocity().isNull())
 		moveBy(velocity().x(), velocity().y());
+#endif
 }
 
 void Ball::collisionDetect()
--- trunk/KDE/kdegames/kolf/ball.h #1191717:1191718
@@ -20,6 +20,7 @@
 #ifndef KOLF_BALL_H
 #define KOLF_BALL_H
 
+#define BALL_BOX2D_STEPPING 1
 #include "canvasitem.h"
 
 class Wall;
@@ -51,6 +52,11 @@
 	void friction();
 	void collisionDetect();
 
+#if BALL_BOX2D_STEPPING
+	virtual void setVelocity(const Vector& velocity);
+	Vector velocity() const { return CanvasItem::physicalVelocity(); }
+#endif
+
 	int addStroke() const { return m_addStroke; }
 	bool placeOnGround(Vector &v) { v = m_pogOldVelocity; return m_placeOnGround; }
 	void setAddStroke(int newStrokes) { m_addStroke = newStrokes; }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic