[Orxonox-commit 5503] r10166 - in code/branches/surfaceraceHS14: data/levels data/levels/templates data/overlays src/modules/dodgerace2
sriedel at orxonox.net
sriedel at orxonox.net
Wed Dec 10 15:40:06 CET 2014
Author: sriedel
Date: 2014-12-10 15:40:05 +0100 (Wed, 10 Dec 2014)
New Revision: 10166
Modified:
code/branches/surfaceraceHS14/data/levels/DodgeRace.oxw
code/branches/surfaceraceHS14/data/levels/templates/spaceshipDodgeRace.oxt
code/branches/surfaceraceHS14/data/overlays/DodgeRaceHUD.oxo
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc
Log:
Final version
Modified: code/branches/surfaceraceHS14/data/levels/DodgeRace.oxw
===================================================================
--- code/branches/surfaceraceHS14/data/levels/DodgeRace.oxw 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/data/levels/DodgeRace.oxw 2014-12-10 14:40:05 UTC (rev 10166)
@@ -1,8 +1,8 @@
<LevelInfo
name = "Dodge Race"
- description = "2D Arcade shooter. Maximise your points!!!\nTip: try to keep the multiplier high by avoiding shots and enemies."
+ description = "Try to come as far as possible"
tags = "minigame"
- screenshot = "orxonoxArcade.png"
+ screenshot = "DodgeRace.png"
/>
<?lua
include("stats.oxo")
@@ -15,7 +15,7 @@
include("templates/spaceshipDodgeRace.oxt")
include("templates/enemyInvader.oxt")
include("templates/DodgeRacePattern.oxt")
- include("overlays/InvaderHUD.oxo")
+ include("overlays/DodgeRaceHUD.oxo")
?>
<Level gametype = DodgeRace>
Modified: code/branches/surfaceraceHS14/data/levels/templates/spaceshipDodgeRace.oxt
===================================================================
--- code/branches/surfaceraceHS14/data/levels/templates/spaceshipDodgeRace.oxt 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/data/levels/templates/spaceshipDodgeRace.oxt 2014-12-10 14:40:05 UTC (rev 10166)
@@ -68,9 +68,10 @@
<Template name=spaceshipescortcameras defaults=0>
<DodgeRaceShip>
<camerapositions>
- <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
- <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
- <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
+ <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
+ <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true />
+ <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
+ <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
</camerapositions>
</DodgeRaceShip>
</Template>
Modified: code/branches/surfaceraceHS14/data/overlays/DodgeRaceHUD.oxo
===================================================================
--- code/branches/surfaceraceHS14/data/overlays/DodgeRaceHUD.oxo 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/data/overlays/DodgeRaceHUD.oxo 2014-12-10 14:40:05 UTC (rev 10166)
@@ -5,18 +5,7 @@
<Template name="DodgeRaceHUD">
<OverlayGroup name="DodgeRaceHUD" scale = "1, 1">
- <DodgeRaceHUDinfo
- position = "0.14, 0.02"
- pickpoint = "0.0, 0.0"
- font = "ShareTechMono"
- textsize = 0.04
- colour = "1.0, 1.0, 1.0, 1.0"
- align = "left"
- showlives = true
- showlevel = false
- showpoints = false
- />
<OverlayText
position = "0.02, 0.02"
pickpoint = "0.0, 0.0"
@@ -24,90 +13,26 @@
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
align = "left"
- caption = "Lives: "
- />
-
- <OverlayText
- position = "0.02, 0.055"
- pickpoint = "0.0, 0.0"
- font = "ShareTechMono"
- textsize = 0.04
- colour = "1.0, 1.0, 1.0, 1.0"
- align = "left"
- caption = "Level: "
- />
-
- <DodgeRaceHUDinfo
- position = "0.14, 0.055"
- pickpoint = "0.0, 0.0"
- font = "ShareTechMono"
- textsize = 0.04
- colour = "1.0, 1.0, 1.0, 1.0"
- align = "left"
-
- showlives = false
- showlevel = true
- showpoints = false
- />
-
- <OverlayText
- position = "0.02, 0.1"
- pickpoint = "0.0, 0.0"
- font = "ShareTechMono"
- textsize = 0.04
- colour = "1.0, 1.0, 1.0, 1.0"
- align = "left"
caption = "Points: "
/>
<DodgeRaceHUDinfo
- position = "0.14, 0.1"
+ position = "0.14, 0.02"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
align = "left"
- showlives = false
- showlevel = false
showpoints = true
/>
- <DodgeRaceHUDinfo
- position = "0.25, 0.1"
- pickpoint = "0.0, 0.0"
- font = "ShareTechMono"
- textsize = 0.04
- colour = "1.0, 1.0, 1.0, 1.0"
- align = "left"
-
- showMultiplier = true
- />
+
</OverlayGroup>
</Template>
-
<Template name="spaceshiphud">
<OverlayGroup name = "spaceshiphud" scale = "1, 1">
- <HUDHealthBar
- name = "HealthBar1"
- background = "Orxonox/HealthBarBackground"
- size = "0.35, 0.0875"
- position = "0.0 , 0.9 "
- pickpoint = "0, 1"
- bartexture = "healthbar_bar.png"
- textfont = "VeraMono"
- textusebarcolour = true
- textsize = 0.039
- textoffset = "0.315, 0.05"
- textpickpoint = "0, 0"
- textalign = "right"
- correctaspect = false
- textcorrectaspect = false
- >
- <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
- <BarColour position = 0.5 colour = "0.7,0.7,0.2" />
- <BarColour position = 1.0 colour = "0.2,0.7,0.2" />
- </HUDHealthBar>
+
</OverlayGroup>
</Template>
\ No newline at end of file
Modified: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc 2014-12-10 14:40:05 UTC (rev 10166)
@@ -45,20 +45,20 @@
init();
this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
this->center_ = 0;
- /*
- this->setHUDTemplate("DodgeRaceHUD"); // !!!!!!!!!!!!!!! change later*/
+
+ this->setHUDTemplate("DodgeRaceHUD");
}
void DodgeRace::init()
{
bEndGame = false;
- lives = 3;
+ lives = 1;
level = 1;
point = 0;
bShowLevel = false;
multiplier = 1;
b_combo = false;
- counter = 0;
+ counter = 5000;
pattern = 1;
lastPosition = 0;
// spawn enemy every 3.5 seconds
@@ -94,8 +94,10 @@
currentPosition = getPlayer()->getWorldPosition().x;
counter = counter + (currentPosition - lastPosition);
lastPosition = currentPosition;
+ point = currentPosition;
+ getPlayer()->speed = 830 - (point / 1000);
- for(int i=0; i< cubeList.size();i++)
+ for(uint i=0; i < cubeList.size();i++)
{
if(cubeList.at(i)->getPosition().x < currentPosition-3000)
{
@@ -107,7 +109,6 @@
if(counter >= 3000)
{
counter = 0;
-
for(int i = 0; i<6; i++)
{
WeakPtr<DodgeRaceCube> cube = new DodgeRaceCube(this->center_->getContext());
@@ -146,38 +147,11 @@
}
return player;
}
-/*
- void DodgeRace::spawnEnemy()
- {
- if (getPlayer() == NULL)
- return;
- for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
- {
- WeakPtr<DodgeRaceEnemy> newPawn;
- if (rand() % 42/(1 + level*level) == 0)
- {
- newPawn = new DodgeRaceEnemyShooter(this->center_->getContext());
- newPawn->addTemplate("enemyinvadershooter");
- }
- else
- {
- newPawn = new DodgeRaceEnemy(this->center_->getContext());
- newPawn->addTemplate("enemyinvader");
- }
- newPawn->setPlayer(player);
- newPawn->level = level;
- // spawn enemy at random points in front of player.
- newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
- }
- }
-*/
void DodgeRace::costLife()
{
- orxout() << "CostLife" << endl;
- endGameTimer.setTimer(3.0f, false, createExecutor(createFunctor(&DodgeRace::end, this)));
-
- multiplier = 1;
+ //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this)));
+ lives = 0;
};
void DodgeRace::comboControll()
@@ -192,9 +166,9 @@
void DodgeRace::start()
{
- orxout() << "start function called." << endl;
+ orxout() << "start" << endl;
init();
- for(int i=0; i< cubeList.size();i++)
+ for(uint i=0; i< cubeList.size();i++)
{
cubeList.at(i)->destroy();
cubeList.erase(cubeList.begin()+i);
@@ -202,7 +176,7 @@
}
cubeList.clear();
// Set variable to temporarily force the player to spawn.
- this->bForceSpawn_ = true;
+ this->bForceSpawn_ = false;
if (this->center_ == NULL) // abandon mission!
{
@@ -213,6 +187,30 @@
// Call start for the parent class.
Deathmatch::start();
}
+
+ void DodgeRace::playerPreSpawn(PlayerInfo* player)
+ {
+ if(lives <= 0)
+ {
+ this->end();
+ }
+
+ // Reset all the cubes
+ /*
+ orxout() << "prespawn" << endl;
+ init();
+ for(int i=0; i< cubeList.size();i++)
+ {
+ cubeList.at(i)->destroy();
+ cubeList.erase(cubeList.begin()+i);
+ }
+ cubeList.clear();
+ lives = 1;
+ point = 0;
+ lastPosition = 0;
+ */
+ }
+
void DodgeRace::addPoints(int numPoints)
{
if (!bEndGame)
Modified: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h 2014-12-10 14:40:05 UTC (rev 10166)
@@ -76,6 +76,8 @@
virtual void tick(float dt);
+ virtual void playerPreSpawn(PlayerInfo* player);
+
void levelUp();
int getLives(){return this->lives;}
Modified: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc 2014-12-10 14:40:05 UTC (rev 10166)
@@ -40,85 +40,39 @@
RegisterObject(DodgeRaceHUDinfo);
this->DodgeRaceGame = 0;
- this->bShowLives_ = false;
- this->bShowLevel_ = false;
- this->bShowPoints_ = false;
- this->bShowMultiplier_ = false;
+ this->bShowPoints_ = true;
}
-/*
+
void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode);
- XMLPortParam(DodgeRaceHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
- XMLPortParam(DodgeRaceHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
- XMLPortParam(DodgeRaceHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false);
- XMLPortParam(DodgeRaceHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false);
+ XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
}
void DodgeRaceHUDinfo::tick(float dt)
{
SUPER(DodgeRaceHUDinfo, tick, dt);
- if (this->DodgeRaceGame)
- {
- if (this->bShowLives_)
- {
- const std::string& lives = multi_cast<std::string>(this->DodgeRaceGame->getLives());
- this->setCaption(lives);
- }
- else if(this->bShowLevel_)
- {
- const std::string& Level = multi_cast<std::string>(this->DodgeRaceGame->getLevel());
- if (this->DodgeRaceGame->lives <= 0)
- {
- setPosition(Vector2(0.1, 0.65));
- this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
- setTextSize(0.05);
- this->DodgeRaceGame->bEndGame = true;
- }
- else if (this->DodgeRaceGame->bShowLevel)
- {
- setTextSize(0.1);
- setPosition(Vector2(0.3, 0.55));
- std::stringstream sstm;
- sstm << "Level " << Level;
- this->setCaption(sstm.str()); // + level
- }
- else
- {
- setTextSize(0.04);
- setPosition(Vector2(0.14, 0.055));
- this->setCaption(Level);
- }
- }
- else if(this->bShowPoints_)
- {
- const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
- if (this->DodgeRaceGame->lives <= 0)
- {
- setTextSize(0.2);
- setPosition(Vector2(0.1, 0.25));
- this->setCaption("Final score:\n" + points);
- this->setColour(ColourValue(1, 0, 0, 1));
- }
- else
- {
- setTextSize(0.04);
- setPosition(Vector2(0.14, 0.1));
- this->setColour(ColourValue(1, 1, 1, 1));
- this->setCaption(points);
- }
- }
- else if(this->bShowMultiplier_)
- {
- int mult = this->DodgeRaceGame->getMultiplier();
- const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
- this->setCaption(Multiplier);
- this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
- this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f);
- }
- }
+
+ if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
+ if (this->DodgeRaceGame->lives <= 0)
+ {
+ setTextSize(0.2);
+ setPosition(Vector2(0.1, 0.02));
+ this->setCaption("Final score:\n" + points);
+ this->setColour(ColourValue(1, 0, 0, 1));
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.02));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(points);
+ }
+ }
}
void DodgeRaceHUDinfo::changedOwner()
@@ -133,5 +87,5 @@
{
this->DodgeRaceGame = 0;
}
- }*/
+ }
}
Modified: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h 2014-12-10 14:40:05 UTC (rev 10166)
@@ -43,37 +43,19 @@
public:
DodgeRaceHUDinfo(Context* context);
- // virtual void tick(float dt);
- // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- //virtual void changedOwner();
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
- inline void setShowLives(bool value)
- { this->bShowLives_ = value; }
- inline bool getShowLives() const
- { return this->bShowLives_; }
-
- inline void setShowLevel(bool value)
- { this->bShowLevel_ = value; }
- inline bool getShowLevel() const
- { return this->bShowLevel_; }
-
inline void setShowPoints(bool value)
{ this->bShowPoints_ = value; }
inline bool getShowPoints() const
{ return this->bShowPoints_; }
- inline void setShowMultiplier(bool value)
- { this->bShowMultiplier_ = value; }
- inline bool getShowMultiplier() const
- { return this->bShowMultiplier_; }
-
private:
DodgeRace* DodgeRaceGame;
- bool bShowLives_;
- bool bShowLevel_;
bool bShowPoints_;
- bool bShowMultiplier_;
};
}
#endif /* _DodgeRaceHUDinfo_H__ */
Modified: code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc
===================================================================
--- code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc 2014-12-10 14:19:06 UTC (rev 10165)
+++ code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc 2014-12-10 14:40:05 UTC (rev 10166)
@@ -41,7 +41,7 @@
{
RegisterObject(DodgeRaceShip);
- speed = 800;
+ speed = 830;
isFireing = false;
damping = 10;
@@ -67,14 +67,14 @@
if (this->hasLocalController())
{
float dist_y = velocity.y * dt;
- float dist_x = velocity.x * dt;
+ //float dist_x = velocity.x * dt;
if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
posforeward += dist_y;
else
{
velocity.y = 0;
// restart if game ended
- /*
+/*
if (getGame())
if (getGame()->bEndGame)
{
@@ -82,23 +82,11 @@
return;
}*/
}
- /*
- if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
- {
- velocity.x = 0;
- }
- */
+
pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
}
- // shoot!
- if (isFireing)
- {
- //pos += Vector3(900, 0, 0) * dt;
- //ControllableEntity::fire(0);
- }
-
// Camera
WeakPtr<Camera> camera = this->getCamera();
if (camera != NULL)
@@ -149,18 +137,11 @@
}
void DodgeRaceShip::boost(bool bBoost)
{
- //isFireing = bBoost;
+ //getGame()->bEndGame = bBoost;
}
inline bool DodgeRaceShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
- /*
- if (otherObject != NULL && lastEntity != otherObject)
- {
- lastEntity = otherObject;
- removeHealth(20);
- }
- */
removeHealth(100);
this->death();
More information about the Orxonox-commit
mailing list