[Orxonox-commit 5437] r10100 - in code/branches/minigame4DHS14: data/levels src/modules/mini4Dgame
richtero at orxonox.net
richtero at orxonox.net
Wed Oct 29 13:21:54 CET 2014
Author: richtero
Date: 2014-10-29 13:21:53 +0100 (Wed, 29 Oct 2014)
New Revision: 10100
Added:
code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt
Modified:
code/branches/minigame4DHS14/data/levels/4Dtest.oxw
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
Log:
CMakeList added
Modified: code/branches/minigame4DHS14/data/levels/4Dtest.oxw
===================================================================
--- code/branches/minigame4DHS14/data/levels/4Dtest.oxw 2014-10-22 14:15:31 UTC (rev 10099)
+++ code/branches/minigame4DHS14/data/levels/4Dtest.oxw 2014-10-29 12:21:53 UTC (rev 10100)
@@ -59,8 +59,7 @@
</attached>
</Mini4DgameCenterpoint>
-
- <!-- Blinking Slot Selector -->
+ <!-- Blinking Slot Selector
<BlinkingBillboard position="0,0,0" frequency=0.6 amplitude=0.4 material="Flares/lensflare" colour="1,1,0.05">
<events>
<visibility>
@@ -74,7 +73,7 @@
</visibility>
</events>
</BlinkingBillboard>
-
+ -->
<!-- Planet in the middle
<Planet
position="0,0,0"
Added: code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt (rev 0)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/CMakeLists.txt 2014-10-29 12:21:53 UTC (rev 10100)
@@ -0,0 +1,15 @@
+SET_SOURCE_FILES(Mini4Dgame_SRC_FILES
+BUILD_UNIT mini4DgameBuildUnit.cc
+ Mini4Dgame.cc
+ Mini4DgameCenterpoint.cc
+END_BUILD_UNIT
+)
+
+ORXONOX_ADD_LIBRARY(mini4Dgame
+ MODULE
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ SOURCE_FILES ${Mini4Dgame_SRC_FILES}
+)
Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc 2014-10-22 14:15:31 UTC (rev 10099)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc 2014-10-29 12:21:53 UTC (rev 10100)
@@ -61,9 +61,8 @@
{
RegisterObject(Mini4Dgame);
- this->center_ = 0;
- this->player_[0] = NULL;
- this->player_[1] = NULL;
+ this->center_ = NULL;
+ //TODO: player Null setzen
}
/**
@@ -133,7 +132,6 @@
Deathmatch::end();
}
----------------------------------------------------------------------------------------------------------------------------------
/**
@brief
@@ -141,25 +139,15 @@
*/
void Mini4Dgame::spawnPlayersIfRequested()
{
- // Spawn a human player.
+ // first spawn human players to assign always the left bat to the player in singleplayer
for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
this->spawnPlayer(it->first);
+ // now spawn bots
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
+ this->spawnPlayer(it->first);
}
-
- bool Tetris::playerLeft(PlayerInfo* player)
- {
- bool left = Gametype::playerLeft(player);
- if(player && player->isHumanPlayer())
- {
- if(this->activeBrick_ != NULL)
- {
- this->player_->stopControl();
- }
- this->cleanup();
- }
- return left;
- }
/**
@brief
@@ -167,149 +155,31 @@
@param player
The player to be spawned.
*/
- void Tetris::spawnPlayer(PlayerInfo* player)
+ void Mini4Dgame::spawnPlayer(PlayerInfo* player)
{
assert(player);
- if(this->player_ == NULL)
+ if(false)//this->player_ == NULL)
{
- this->player_ = player;
+ //this->player_ = player;
this->players_[player].state_ = PlayerState::Alive;
}
}
-
- void Tetris::startBrick(void)
- {
- if(this->player_ == NULL)
- return;
-
- unsigned int cameraIndex = 0;
- if(this->activeBrick_ != NULL)
- {
- // Get camera settings
- cameraIndex = this->activeBrick_->getCurrentCameraIndex();
- this->player_->stopControl();
- // destroy old active brick
- this->activeBrick_->destroy();
- }
-
- // Make the last brick to be created the active brick.
- this->activeBrick_ = this->futureBrick_;
- this->futureBrick_ = 0;
-
- // set its position
- this->player_->startControl(this->activeBrick_);
- float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
- float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
- this->activeBrick_->setPosition(xPos, yPos, 0.0f);
- this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
- this->activeBrick_->setCameraPosition(cameraIndex);
-
- // create a new future brick
- this->createBrick();
-
- // check if the new brick is in a valid position, otherwise end the game
- if (!this->isValidBrickPosition(this->activeBrick_))
- this->end();
- }
-
- 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());
-
- // 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);
- }
-
-
/**
@brief
Get the player.
@return
Returns a pointer to the player. If there is no player, NULL is returned.
*/
- PlayerInfo* Tetris::getPlayer(void) const
+ //TODO: colors
+ PlayerInfo* Mini4Dgame::getPlayer(int color) const
{
- return this->player_;
+ return players[color];
+ //for(int i=0;i<NUMBEROFPLAYERS;i++)
+ //if(color == this->mini4DgamePlayers[i].color)
+ //return this->mini4DgamePlayers[i].info;
}
- /*TetrisCenterpoint* Tetris::getCenterpoint(void) const
- {
- return this->center_;
- }*/
-
- /**
- @brief Set the TetrisCenterpoint (the playing field).
- @param center A pointer to the TetrisCenterpoint to be set.
- */
- void Tetris::setCenterpoint(TetrisCenterpoint* center)
- {
- this->center_ = center;
- }
-
- /**
- @brief Check each row if it is full. Removes all full rows. Update
- @brief Manages score.
- */
- void Tetris::findFullRows()
- {
- unsigned int correctPosition = 0;
- unsigned int stonesPerRow = 0;
- for (unsigned int row = 0; row < this->center_->getHeight(); row++)
- {
- stonesPerRow = 0;
- for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
- {
- std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;
- correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
- if(correctPosition == row)
- {
- stonesPerRow++;
- if(stonesPerRow == this->center_->getWidth())
- {
- clearRow(row);
- row--; //the row counter has to be decreased in order to detect multiple rows!
- this->playerScored(this->player_);// add points
- //increase the stone's speed
- this->center_->setStoneSpeed(this->center_->getStoneSpeed()+1.0f);
- }
- }
- }
- }
- }
-
- void Tetris::clearRow(unsigned int row)
- {// clear the full row
- for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
- {
- if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
- {
- (*it)->destroy();
- this->stones_.erase(it++);
- }
- else
- ++it;
- }
- // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
- for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
- {
- if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
- (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));
- }
-
- }
-
-
}
Modified: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h 2014-10-22 14:15:31 UTC (rev 10099)
+++ code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.h 2014-10-29 12:21:53 UTC (rev 10100)
@@ -38,7 +38,6 @@
namespace orxonox
{
-
/**
@brief
@@ -55,13 +54,12 @@
virtual void end(void); ///!< Ends the Mini4Dgame minigame.
virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
- virtual bool playerLeft(PlayerInfo* player);
void setCenterpoint(Mini4DgameCenterpoint* center)
{ this->center_ = center; }
- PlayerInfo* getLeftPlayer() const; //!< Get the left player.
- PlayerInfo* getRightPlayer() const; //!< Get the right player.
+//TODO: enum colors
+ PlayerInfo* getPlayer(int color) const; //!< Get the player with the specified color.
//bool isValidMove(Vector4* move, const Mini4DgameBoard* board);//!< Checks if the move is valid
@@ -73,7 +71,7 @@
private:
void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
- PlayerInfo* player_[2];//!< The two players
+ PlayerInfo* players[3];
WeakPtr<Mini4DgameCenterpoint> center_; //!< The playing field.
More information about the Orxonox-commit
mailing list