[Orxonox-commit 3942] r8616 - in code/branches/spacerace: data/levels src/modules/gametypes
msalomon at orxonox.net
msalomon at orxonox.net
Thu May 26 22:03:33 CEST 2011
Author: msalomon
Date: 2011-05-26 22:03:32 +0200 (Thu, 26 May 2011)
New Revision: 8616
Modified:
code/branches/spacerace/data/levels/spaceRace.oxw
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h
code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
code/branches/spacerace/src/modules/gametypes/SpaceRace.h
Log:
RaceCheckPoints with a time limit and the version of the level for the presentation.
Modified: code/branches/spacerace/data/levels/spaceRace.oxw
===================================================================
--- code/branches/spacerace/data/levels/spaceRace.oxw 2011-05-26 16:01:34 UTC (rev 8615)
+++ code/branches/spacerace/data/levels/spaceRace.oxw 2011-05-26 20:03:32 UTC (rev 8616)
@@ -40,6 +40,8 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SimpleNotification message="Reach the last check point within 150 seconds!!" />
+
<!-- ------------------SpawnPoint----------------- -->
<SpawnPoint position="0,-2100,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="true" >
<events>
@@ -71,7 +73,7 @@
<RaceCheckPoint name="checkpoint2" position="0,-900,2300" stayActive="true" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
- <SpawnPoint position="0,0,0" lookat="0,700,2700" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -105,7 +107,7 @@
<RaceCheckPoint name="checkpoint3" position="0,700,2700" stayActive="true" direction="0,0,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
- <SpawnPoint position="0,0,0" lookat="0,2100,2300" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -140,7 +142,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger3" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,2200,500" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -175,7 +177,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger4" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,1500,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -210,7 +212,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger5" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,200,-1900" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -245,7 +247,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger6" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,-700,-1400" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -280,7 +282,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger7" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,-1300,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<Trigger mode="xor" invert="true" >
@@ -315,7 +317,7 @@
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger8" position="0,0,0" distance=40 stayActive="true" />
- <SpawnPoint position="0,0,0" lookat="0,-2400,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
+ <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >
<events>
<activity>
<EventTrigger>
@@ -442,14 +444,31 @@
</MovableEntity>
<!-- ---------------SpaceShips----------------- -->
- <SpaceShip position="0,2000,2000" lookat="0,0,0" >
+ <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 >
<templates>
<Template link=spaceshipassff />
</templates>
<controller>
- <AIController />
+ <WaypointPatrolController alertnessradius=1500 team=0 >
+ <waypoints>
+ <Model scale=0 position="0,2000,2000" />
+ </waypoints>
+ </WaypointPatrolController>
</controller>
</SpaceShip>
+ <SpaceShip position="0,2000,-2000" lookat="0,0,0" team=1 >
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=1500 team=0 >
+ <waypoints>
+ <Model scale=0 position="0,2000,-2000" />
+ </waypoints>
+ </WaypointPatrolController>
+ </controller>
+ </SpaceShip>
+
</Scene>
</Level>
Modified: code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc 2011-05-26 16:01:34 UTC (rev 8615)
+++ code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc 2011-05-26 20:03:32 UTC (rev 8616)
@@ -31,6 +31,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "SpaceRace.h"
+#include "util/Convert.h"
namespace orxonox
{
@@ -46,8 +47,8 @@
this->bIsLast_ = false;
this->bTimeLimit_ = 0;
- this->setRadarObjectColour(ColourValue::Red);
- this->setRadarObjectShape(RadarViewable::Dot);
+ this->setRadarObjectColour(ColourValue::Blue);
+ this->setRadarObjectShape(RadarViewable::Triangle);
this->setRadarVisibility(false);
}
@@ -62,14 +63,6 @@
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true);
else this->setRadarVisibility(false);
-
- if (this->bTimeLimit_ != 0 && gametype->getTimerIsActive()) {
- float time = gametype->getTime() - this->bTimeLimit_;
- if (time > 0) {
- gametype->timeIsUp();
- gametype->end();
- }
- }
}
@@ -91,7 +84,13 @@
{
if (this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
{
- if (this->getLast())
+ gametype->clock_->capture();
+ float time = gametype->clock_->getSecondsPrecise();
+ if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) {
+ gametype->timeIsUp();
+ gametype->end();
+ }
+ else if (this->getLast())
{
gametype->end();
}
@@ -104,4 +103,20 @@
}
}
+ void RaceCheckPoint::setTimelimit(float timeLimit)
+ {
+ this->bTimeLimit_ = timeLimit;
+ if (this->bTimeLimit_ != 0)
+ {
+ SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+ if (gametype)
+ {
+ const std::string& message = "You have " + multi_cast<std::string>(this->bTimeLimit_)
+ + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1) + "\n";
+ COUT(0) << message;
+ const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
+ }
+ }
+ }
+
}
Modified: code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h 2011-05-26 16:01:34 UTC (rev 8615)
+++ code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h 2011-05-26 20:03:32 UTC (rev 8616)
@@ -37,6 +37,11 @@
namespace orxonox
{
+ /**
+ @brief
+ The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
+ !!! Don't forget to controll the indexes of your check points and to set one last check point!!!
+ */
class _ObjectsExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
{
public:
@@ -56,17 +61,16 @@
{ this->bCheckpointIndex_ = checkpointIndex; }
inline int getCheckpointIndex()
{ return this->bCheckpointIndex_; }
- inline void setTimelimit(int timeLimit)
- { this->bTimeLimit_ = timeLimit;}
- inline int getTimeLimit()
+ virtual void setTimelimit(float timeLimit);
+ inline float getTimeLimit()
{ return this->bTimeLimit_;}
inline const WorldEntity* getWorldEntity() const
{ return this; }
private:
- int bCheckpointIndex_;
- bool bIsLast_;
- int bTimeLimit_;
+ int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes.
+ bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
+ float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
};
}
Modified: code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spacerace/src/modules/gametypes/SpaceRace.cc 2011-05-26 16:01:34 UTC (rev 8615)
+++ code/branches/spacerace/src/modules/gametypes/SpaceRace.cc 2011-05-26 20:03:32 UTC (rev 8616)
@@ -41,7 +41,7 @@
SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
{
RegisterObject(SpaceRace);
- this->checkpointsReached_ = 0;
+ this->bCheckpointsReached_ = 0;
this->bTimeIsUp_ = false;
this->numberOfBots_ = 0;
}
@@ -54,17 +54,23 @@
void SpaceRace::end()
{
Gametype::end();
- this->stopTimer();
if (this->bTimeIsUp_) {
- COUT(0) << "Time is up" << std::endl;
- const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up");
+ this->clock_->capture();
+ int s = this->clock_->getSeconds();
+ int ms = this->clock_->getMilliseconds()-1000*s;
+ const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
+ + "You didn't reach the check point" + multi_cast<std::string>(this->bCheckpointsReached_+1)
+ + " before the time limit. You loose!\n";
+ COUT(0) << message;
+ const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ Host::Broadcast(message);
}
else {
this->clock_->capture();
int s = this->clock_->getSeconds();
int ms = this->clock_->getMilliseconds()-1000*s;
- const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +
- "." + multi_cast<std::string>(ms) + " seconds.";
+ const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
+ + "." + multi_cast<std::string>(ms) + " seconds.\n";
COUT(0) << message << std::endl;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
Host::Broadcast(message);
@@ -80,7 +86,6 @@
{
Gametype::start();
- this->startTimer();
clock_= new Clock();
std::string message("The match has started! Reach the check points as quickly as possible!");
COUT(0) << message << std::endl;
@@ -89,13 +94,13 @@
void SpaceRace::newCheckpointReached()
{
- this->checkpointsReached_++;
+ this->bCheckpointsReached_++;
this->clock_->capture();
int s = this->clock_->getSeconds();
int ms = this->clock_->getMilliseconds()-1000*s;
const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
+ " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
- + " seconds.";
+ + " seconds.\n";
COUT(0) << message << std::endl;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
Host::Broadcast(message);
Modified: code/branches/spacerace/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spacerace/src/modules/gametypes/SpaceRace.h 2011-05-26 16:01:34 UTC (rev 8615)
+++ code/branches/spacerace/src/modules/gametypes/SpaceRace.h 2011-05-26 20:03:32 UTC (rev 8616)
@@ -39,26 +39,10 @@
namespace orxonox
{
-/* class PlayerScore {
- public:
- PlayerScore() {
- this->name = "";
- this->time =0;
- }
- PlayerScore(std::string name, float time) {
- this->name_ = name;
- this->time_ = time;
- }
- PlayerScore(float time) {
- this->name_ = "Player";
- this->time_ = time;
- }
-
- private:
- std::string name_;
- float time_;
- };*/
-
+ /**
+ @brief
+ The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
+ */
class _OrxonoxExport SpaceRace : public Gametype
{
public:
@@ -73,19 +57,18 @@
virtual void newCheckpointReached();
inline void setCheckpointsReached(int n)
- { this->checkpointsReached_ = n;}
+ { this->bCheckpointsReached_ = n;}
inline int getCheckpointsReached()
- { return this->checkpointsReached_; }
+ { return this->bCheckpointsReached_; }
inline void timeIsUp()
{ this->bTimeIsUp_ = true;}
-
+ Clock *clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
protected:
private:
- int checkpointsReached_;
- std::set<float> scores_;
- Clock *clock_;
- bool bTimeIsUp_;
+ int bCheckpointsReached_; //The current number of check points reached by the player.
+ std::set<float> scores_; //The times of the players are saved in a set.
+ bool bTimeIsUp_; //True if one of the check points is reached too late.
};
}
More information about the Orxonox-commit
mailing list