[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/kolf-ng
From: Stefan Majewsky <majewsky () gmx ! net>
Date: 2009-07-31 22:41:28
Message-ID: 1249080088.712452.29181.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1005390 by majewsky:
Replace the weird instances list from Kolf::CourseMetaObject with a proper solution, \
thereby fixing a bug with the ball positioning.
M +0 -4 elements/object-coursemeta.cpp
M +0 -3 elements/object-coursemeta.h
M +9 -2 elements/scene.cpp
M +0 -6 engine/player.cpp
--- trunk/playground/games/kolf-ng/elements/object-coursemeta.cpp #1005389:1005390
@@ -24,19 +24,15 @@
BIND_KOLF_OBJECT(Kolf::CourseMetaObject)
-QList<Kolf::CourseMetaObject*> Kolf::CourseMetaObject::Instances; //initialization
-
Kolf::CourseMetaObject::CourseMetaObject(dWorldID worldID, dSpaceID spaceID)
: Kolf::Object(worldID, spaceID)
, m_hasCourseBoundary(false)
{
- Instances << this;
}
Kolf::CourseMetaObject::~CourseMetaObject()
{
qDeleteAll(m_courseBoundaryComponents);
- Instances.removeAll(this);
}
bool Kolf::CourseMetaObject::hasCourseBoundary() const
--- trunk/playground/games/kolf-ng/elements/object-coursemeta.h #1005389:1005390
@@ -40,8 +40,6 @@
CourseMetaObject(dWorldID worldID, dSpaceID spaceID);
virtual ~CourseMetaObject();
- static QList<Kolf::CourseMetaObject*> Instances;
-
bool hasCourseBoundary() const;
void setCourseBoundary(bool hasCourseBoundary);
protected:
@@ -49,7 +47,6 @@
private:
bool m_hasCourseBoundary;
QList<Kolf::WallObjectPointer> m_courseBoundaryComponents;
-
};
}
--- trunk/playground/games/kolf-ng/elements/scene.cpp #1005389:1005390
@@ -19,7 +19,7 @@
#include "scene.h"
#include "ball.h"
#include "managedobjectgroup.h"
-#include "objectfactory.h"
+#include "object-coursemeta.h"
#include <ode/ode.h>
@@ -81,10 +81,17 @@
Kolf::Ball* Kolf::Scene::addBall()
{
- Kolf::Ball* ball = \
reinterpret_cast<Kolf::Ball*>(Kolf::ObjectFactory::create("Kolf::Ball", this)); \
+ //create ball + Kolf::Ball* ball = new Kolf::Ball(m_worldID, m_spaceID);
addItem(ball);
m_balls << ball;
m_objects << ball;
+ //set ball to the position specified in the course meta object (if there is one)
+ Kolf::CourseMetaObject* cmObject = \
m_objects.allOfType<Kolf::CourseMetaObject>().value(0); + if (cmObject)
+ ball->setPosition(cmObject->position());
+ else
+ ball->setPosition(Kolf::PointF(500, 500, 100)); //a sane fallback above the middle \
of the scene return ball;
}
--- trunk/playground/games/kolf-ng/engine/player.cpp #1005389:1005390
@@ -18,7 +18,6 @@
#include "player.h"
#include "../elements/ball.h"
-#include "../elements/object-coursemeta.h"
#include "../elements/scene.h"
Kolf::Player::Player(const QString& name, unsigned int holeCount)
@@ -43,11 +42,6 @@
{
m_ball = m_scene->addBall();
m_ball->setColor(QColor::fromHsv(m_hue, 255, 255));
- //find position of ball in course meta object
- if (Kolf::CourseMetaObject::Instances.isEmpty())
- m_ball->setPosition(Kolf::PointF(500, 500, 0)); //a sane fallback on the middle \
of the scene
- else
- m_ball->setPosition(Kolf::CourseMetaObject::Instances[0]->position());
}
return m_ball;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic