[Orxonox-commit 7714] r12307 - in code/branches/OrxoBlox_FS19: data/levels src/modules/OrxoBlox
ahuwyler at orxonox.net
ahuwyler at orxonox.net
Thu Apr 18 15:00:45 CEST 2019
Author: ahuwyler
Date: 2019-04-18 15:00:44 +0200 (Thu, 18 Apr 2019)
New Revision: 12307
Modified:
code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
Log:
A Stone is in the game/ Templates are ajusted
Modified: code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw 2019-04-18 13:00:44 UTC (rev 12307)
@@ -50,6 +50,42 @@
</OrxoBloxBall>
</Template>
+
+
+<Template name=OrxoBloxStonescameras defaults=0>
+ <OrxoBloxStones>
+ <camerapositions>
+ <CameraPosition position="55,75,200" absolute=true />
+ </camerapositions>
+ </OrxoBloxStones>
+</Template>
+
+<Template name=OrxoBloxstone>
+ <OrxoBloxStones camerapositiontemplate=OrxoBloxStonescameras >
+ <attached>
+ <Model position="0,0,0" mesh="CuboidBody.mesh" scale=4.5 />
+ <Model position="0,0,0" mesh="cube_orange.mesh" scale=4.3 />
+ </attached>
+ </OrxoBloxStones>
+</Template>
+
+<Template name=OrxoBloxWallcameras defaults=0>
+ <OrxoBloxWall>
+ <camerapositions>
+ <CameraPosition position="55,75,200" absolute=true />
+ <!--CameraPosition position="0,50,160" drag=true mouselook=true />
+ <CameraPosition position="0,50,0" pitch=-90 drag=true mouselook=true /-->
+ </camerapositions>
+ </OrxoBloxWall>
+</Template>
+
+<Template name=OrxoBloxwall>
+ <OrxoBloxWall camerapositiontemplate=OrxoBloxWallcameras>
+ </OrxoBloxWall>
+</Template>
+
+
+
<Level
plugins = "OrxoBlox"
gametype = "OrxoBlox"
@@ -73,7 +109,7 @@
<MovableEntity rotationrate=5 rotationaxis="0,0,1">
<attached>
- <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25>
+ <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25 StoneTemplate=OrxoBloxstone WallTemplate=OrxoBloxwall>
<attached>
<!-- Balken die das Spielfeld begrenzen. -->
<Model position="0,0,-50" mesh="cube.mesh" scale3D="60,1,1" />
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-04-18 13:00:44 UTC (rev 12307)
@@ -67,10 +67,11 @@
this->center_ = nullptr;
this->ball_ = nullptr;
- this->bat_[0] = nullptr;
this->futureWall_ = nullptr;
+ this->player_ = nullptr;
+
- //this->setHUDTemplate("pongHUD");
+ this->setHUDTemplate("OrxoBloxHUD");
//Error when specified
// Pre-set the timer, but don't start it yet.
@@ -77,11 +78,8 @@
this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::startBall, this)));
this->starttimer_.stopTimer();
- // Set the type of Bots for this particular Gametype.
- this->botclass_ = Class(OrxoBloxBat);
+
- this->scoreLimit_ = 10;
- this->setConfigValues();
}
/**
@@ -94,11 +92,6 @@
this->cleanup();
}
- void OrxoBlox::setConfigValues()
- {
- SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
- }
-
/**
@brief
Cleans up the Gametype by destroying the ball and the bats.
@@ -111,20 +104,27 @@
this->ball_ = nullptr;
}
- // Destroy both bats, if present.
- for (size_t i = 0; i < 2; ++i)
+ if (this->futureWall_)
+ {
+ this->futureWall_->destroy();
+ this->futureWall_ = nullptr;
+ }
+
+ // Destroy 6 bWalls, if present.
+ for (size_t i = 0; i < 6; ++i)
{
- if (this->bat_[0] != nullptr)
+ if (this->activeWalls_[0] != nullptr)
{
- this->bat_[0]->destroy();
- this->bat_[0] = nullptr;
+ this->activeWalls_[0]->destroy();
+ this->activeWalls_[0] = nullptr;
}
+
}
}
/**
- @brief
+ @brieftt
Starts the OrxoBlox minigame.
*/
void OrxoBlox::start()
@@ -140,12 +140,16 @@
// Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
this->center_->attach(this->ball_);
- this->ball_->setPosition(0,0,50); //Startposition
+ this->ball_->setPosition(0, 0, 50);
this->ball_->setFieldDimension(this->center_->getFieldDimension());
this->ball_->setSpeed(0);
this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());
this->ball_->setBatLength(this->center_->getBatLength());
+
+
+
+
// If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint.
for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_)
{
@@ -156,17 +160,11 @@
}
}
- // Attach the bats to the centerpoint and set the parameters as specified in the centerpoint, the bats are attached to.
- this->center_->attach(this->bat_[0]);
- this->center_->attach(this->bat_[1]);
- this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
- this->bat_[0]->yaw(Degree(-90));
- this->bat_[0]->setSpeed(this->center_->getBatSpeed());
- this->bat_[0]->setFieldHeight(this->center_->getFieldDimension().y);
- this->bat_[0]->setLength(this->center_->getBatLength());
- // Set the bats for the ball.
- this->ball_->setBats(this->bat_);
+ // Create the first Wall.
+ this->createWall();
+ orxout()<< "helloo"<< endl;
+
}
else // If no centerpoint was specified, an error is thrown and the level is exited.
{
@@ -187,7 +185,6 @@
// Reset the variable.
this->bForceSpawn_ = temp;
-
}
/**
@@ -219,6 +216,7 @@
this->spawnPlayer(mapEntry.first);
}
+
/**
@brief
Spawns the input player.
@@ -227,16 +225,13 @@
*/
void OrxoBlox::spawnPlayer(PlayerInfo* player)
{
- assert(player);
+ assert(player);
- // If the first (left) bat has no player.
- if (this->bat_[0]->getPlayer() == nullptr)
+ if(this->player_ == nullptr)
{
- player->startControl(this->bat_[0]);
+ this->player_ = player;
this->players_[player].state_ = PlayerState::Alive;
}
- else
- return;
}
/**
@@ -243,67 +238,42 @@
@brief
Is called when the player scored.
*/
- void OrxoBlox::playerScored(PlayerInfo* player, int score)
- {
- Deathmatch::playerScored(player, score);
+
+ //void startWall(void);
+
- if (this->center_ != nullptr) // If there is a centerpoint.
- {
- // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks.
-
- if (player == this->getLeftPlayer())
- this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left));
- // Also announce, that the player has scored.
- if (player != nullptr)
- this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
- }
+ void OrxoBlox::createWall(void){
+ this->futureWall_ = new OrxoBloxWall(this->center_->getContext());
+ // Apply the stone template to the stone.
+ this->futureWall_->addTemplate(this->center_->getWallTemplate());
- // If there is a ball present, reset its position, velocity and acceleration.
- if (this->ball_ != nullptr)
- {
- this->ball_->setPosition(Vector3::ZERO);
- this->ball_->setVelocity(Vector3::ZERO);
- this->ball_->setAcceleration(Vector3::ZERO);
- this->ball_->setSpeed(0);
- }
-
- // If there are bats reset them to the middle position.
- if (this->bat_[0] != nullptr && this->bat_[1] != nullptr)
- {
- this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
-
- }
-
-
- // Restart the timer to start the ball.
- this->starttimer_.startTimer();
+ // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
+ this->center_->attach(this->futureWall_);
+
+
+ this->futureWall_->setPosition(10, 10, 0.0f);
+ this->futureWall_->setGame(this);
}
- /*void OrxoBlox::createStonewall(void){
- this->futureWall_ = new OrxoBolxWall(this->center_->getContext());
- }
+ // void OrxoBlox::createWall(void) //TODO: random rotation offset between 0 and 3 (times 90°)
+ // {
+ // // create new futureBrick_
+ // this->futureWall_ = new TetrisBrick(this->center_->getContext());
- /*void Tetris::createBrick(void) //TODO: random rotation offset between 0 and 3 (times 90°)
- {
- // create new futureBrick_
- this->futureBrick_ = new TetrisBrick(this->center_->getContext());
+ // // Apply the stone template to the stone.
+ // this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
- // Apply the stone template to the stone.
- this->futureBrick_->addTemplate(this->center_->getBrickTemplate());
-
- // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
- this->center_->attach(this->futureBrick_);
- float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
- float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
+ // // Attach the brick to the Centerpoint and set the position of the brick to be at the left side.
+ // this->center_->attach(this->futureBrick_);
+ // float xPos = (this->center_->getWidth()*1.6f + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
+ // float yPos = (this->center_->getHeight()-5.1f)*this->center_->getStoneSize();
- this->futureBrick_->setPosition(xPos, yPos, 0.0f);
- this->futureBrick_->setGame(this);
- }
+ // this->futureBrick_->setPosition(xPos, yPos, 0.0f);
+ // this->futureBrick_->setGame(this);
+ // }
- }*/
-
/**
@brief
Starts the ball with some default speed.
@@ -314,19 +284,6 @@
this->ball_->setSpeed(this->center_->getBallSpeed());
}
- /**
- @brief
- Get the left player.
- @return
- Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned.
- */
- PlayerInfo* OrxoBlox::getLeftPlayer() const
- {
- if (this->bat_[0] != nullptr)
- return this->bat_[0]->getPlayer();
- else
- return nullptr;
- }
-
+
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h 2019-04-18 13:00:44 UTC (rev 12307)
@@ -73,7 +73,7 @@
virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player.
- virtual void playerScored(PlayerInfo* player, int score = 1) override; //!< Is called when the player scored.
+
/**
@brief Set the OrxoBloxCenterpoint (the playing field).
@@ -81,22 +81,27 @@
*/
void setCenterpoint(OrxoBloxCenterpoint* center)
{ this->center_ = center; }
- void setConfigValues(); //!< Makes scoreLimit configurable.
- PlayerInfo* getLeftPlayer() const; //!< Get the left player.
+ OrxoBloxCenterpoint* getCenterpoint(void)
+ { return this->center_; }
protected:
virtual void spawnPlayersIfRequested() override; //!< Spawns players, and fills the rest up with bots.
-
+ private:
+ void startWall(void);
+ void createWall(void);
void startBall(); //!< Starts the ball with some default speed.
void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field.
WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball.
- WeakPtr<OrxoBloxBat> bat_[1]; //!< The two bats.
+ WeakPtr<OrxoBloxBat> bat_[0]; //!< The two bats.
+ PlayerInfo* player_;
+
Timer starttimer_; //!< A timer to delay the start of the game.
- int scoreLimit_; //!< If a player scored that much points, the game is ended.
+
WeakPtr<OrxoBloxWall> futureWall_;
+ WeakPtr<OrxoBloxWall> activeWalls_[6]; //6 is the number of wallls in the game.
};
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc 2019-04-18 13:00:44 UTC (rev 12307)
@@ -79,6 +79,8 @@
XMLPortParam(OrxoBloxCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
XMLPortParam(OrxoBloxCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
+ XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
XMLPortParam(OrxoBloxCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.h 2019-04-18 13:00:44 UTC (rev 12307)
@@ -216,11 +216,42 @@
float getBatLength() const
{ return this->batlength_; }
+ /**
+ @brief Set the template for the stones.
+ @param templateName The template name to be applied to each stone.
+ */
+ void setStoneTemplate(const std::string& templateName)
+ { this->stoneTemplate_ = templateName; }
+ /**
+ @brief Get the template for the stones.
+ @return Returns the template name to be applied to each stone.
+ */
+ const std::string& getStoneTemplate(void) const
+ { return this->stoneTemplate_; }
+
+
+ /**
+ @brief Set the template for the bricks.
+ @param templateName The template name to be applied to each brick.
+ */
+ void setWallTemplate(const std::string& templateName)
+ { this->WallTemplate_ = templateName; }
+
+ /**
+ @brief Get the template for the bricks.
+ @return Returns the template name to be applied to each brick.
+ */
+ const std::string& getWallTemplate(void) const
+ { return this->WallTemplate_; }
+
+
private:
void checkGametype(); //!< Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
std::string balltemplate_; //!< The template for the ball.
std::string battemplate_; //!< The template for the bats.
+ std::string WallTemplate_;
+ std::string stoneTemplate_;
float ballspeed_; //!< The speed of then ball.
float ballaccfactor_; //!< The acceleration factor of the ball.
@@ -229,6 +260,8 @@
float width_; //!< The height of the playing field.
float height_; //!< The width of the playing field.
+
+
};
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h 2019-04-18 13:00:44 UTC (rev 12307)
@@ -71,9 +71,9 @@
class OrxoBloxAI;
class OrxoBloxBall;
class OrxoBloxBat;
- class OrxoBloxBot;
class OrxoBloxCenterpoint;
- class OrxoBloxScore;
+ class OrxoBloxWall;
+ class OrxobloxStones;
}
#endif /* _OrxoBloxPrereqs_H__ */
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc 2019-04-18 13:00:44 UTC (rev 12307)
@@ -1,4 +1,5 @@
#include "OrxoBloxStones.h"
+
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h 2019-04-18 13:00:44 UTC (rev 12307)
@@ -45,12 +45,15 @@
// else ~OrxoBloxStones();
}
-
+ void setGame(OrxoBlox* orxoblox)
+ { assert(orxoblox); orxoblox_ = orxoblox; }
+
private:
float size_; //!< The dimensions a stone has in the game world.
unsigned int health_;
bool delay_;
+ OrxoBlox* orxoblox_;
};
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc 2019-04-18 13:00:44 UTC (rev 12307)
@@ -15,7 +15,33 @@
{
RegisterObject(OrxoBloxWall);
- this->health_ = 10;
+ this->health_ = 1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7;
this->delay_ = false;
+ this->orxoblox_ = this->getOrxoBlox();
+
+
+ OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
+ if(this->orxoblox_ != nullptr)
+ {
+ stone->setGame(this->orxoblox_);
+ if(this->orxoblox_->getCenterpoint() != nullptr)
+ stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
+ else
+ orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
+ }
+ else
+ orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
}
+
+
+ OrxoBlox* OrxoBloxWall::getOrxoBlox()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
+ return orxobloxGametype;
+ }
+ else orxout()<<"There is no Gametype! ask Anna"<< endl;
+ return nullptr;
+ }
}
\ No newline at end of file
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h 2019-04-18 12:49:44 UTC (rev 12306)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h 2019-04-18 13:00:44 UTC (rev 12307)
@@ -44,13 +44,14 @@
}
// else ~OrxoBloxStones();
}
-
-
+ void setGame(OrxoBlox* orxoblox)
+ { assert(orxoblox); orxoblox_ = orxoblox; }
private:
+ OrxoBlox* getOrxoBlox();
unsigned int health_;
bool delay_;
+ OrxoBlox* orxoblox_;
-
};
}
More information about the Orxonox-commit
mailing list