[Orxonox-commit 3890] r8564 - in code/branches/presentation: . data/levels src/modules src/modules/pong src/modules/tetris
dafrick at orxonox.net
dafrick at orxonox.net
Tue May 24 21:24:40 CEST 2011
Author: dafrick
Date: 2011-05-24 21:24:39 +0200 (Tue, 24 May 2011)
New Revision: 8564
Added:
code/branches/presentation/data/levels/tetris.oxw
code/branches/presentation/src/modules/tetris/
code/branches/presentation/src/modules/tetris/CMakeLists.txt
code/branches/presentation/src/modules/tetris/Tetris.cc
code/branches/presentation/src/modules/tetris/Tetris.h
code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc
code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h
code/branches/presentation/src/modules/tetris/TetrisPrereqs.h
code/branches/presentation/src/modules/tetris/TetrisStone.cc
code/branches/presentation/src/modules/tetris/TetrisStone.h
Removed:
code/branches/presentation/src/modules/tetris/CMakeLists.txt
code/branches/presentation/src/modules/tetris/Tetris.cc
code/branches/presentation/src/modules/tetris/Tetris.h
code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc
code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h
code/branches/presentation/src/modules/tetris/TetrisPrereqs.h
code/branches/presentation/src/modules/tetris/TetrisStone.cc
code/branches/presentation/src/modules/tetris/TetrisStone.h
Modified:
code/branches/presentation/
code/branches/presentation/src/modules/CMakeLists.txt
code/branches/presentation/src/modules/pong/PongBat.h
Log:
Merging tetris branch into presentation branch.
Property changes on: code/branches/presentation
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8107
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/steering:5949-6091
/code/branches/tetris:8100-8563
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Copied: code/branches/presentation/data/levels/tetris.oxw (from rev 8563, code/branches/tetris/data/levels/tetris.oxw)
===================================================================
--- code/branches/presentation/data/levels/tetris.oxw (rev 0)
+++ code/branches/presentation/data/levels/tetris.oxw 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,61 @@
+<LevelInfo
+ name = "Tetris"
+ description = "Tetris in space!"
+ tags = ""
+/>
+
+<?lua
+ include("HUDTemplates3.oxo")
+ include("stats.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<Template name=tetrisstonecameras defaults=0>
+ <TetrisStone>
+ <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>
+ </TetrisStone>
+</Template>
+
+<Template name=tetrisstone>
+ <TetrisStone camerapositiontemplate=tetrisstonecameras>
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale=1 />
+ </attached>
+ </TetrisStone>
+</Template>
+
+<Level
+ name = "Presentation"
+ description = "A simple testlevel"
+ gametype = "Tetris"
+>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+
+ <Scene
+ ambientlight = "0.5, 0.5, 0.5"
+ skybox = "Orxonox/skypanoramagen1"
+ >
+ <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" />
+
+ <?lua
+ for i = 1, 10, 1 do
+ ?>
+ <SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>,<?lua print(math.random() * 1000 - 500) ?>" lookat="0,0,0" />
+ <?lua end ?>
+
+ <TetrisCenterpoint name=tetriscenter width=11 height=15 stoneSize=10 stoneTemplate=tetrisstone stoneSpeed=10 position="-55,-75,0">
+ <attached>
+ <Model position="55,-1,0" mesh="cube.mesh" scale3D="57,1,11" />
+ <Model position="-1,76,0" mesh="cube.mesh" scale3D="1,76,1" />
+ <Model position="111,76,0" mesh="cube.mesh" scale3D="1,76,1" />
+ </attached>
+ </TetrisCenterpoint>
+
+ </Scene>
+</Level>
Modified: code/branches/presentation/src/modules/CMakeLists.txt
===================================================================
--- code/branches/presentation/src/modules/CMakeLists.txt 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/CMakeLists.txt 2011-05-24 19:24:39 UTC (rev 8564)
@@ -33,5 +33,6 @@
ADD_SUBDIRECTORY(pong)
ADD_SUBDIRECTORY(portals)
ADD_SUBDIRECTORY(questsystem)
+ADD_SUBDIRECTORY(tetris)
ADD_SUBDIRECTORY(weapons)
ADD_SUBDIRECTORY(docking)
Modified: code/branches/presentation/src/modules/pong/PongBat.h
===================================================================
--- code/branches/presentation/src/modules/pong/PongBat.h 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/pong/PongBat.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -99,7 +99,7 @@
void setLength(float length)
{ this->length_ = length; }
/**
- @brief get the length of the bat.
+ @brief Get the length of the bat.
@return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
*/
float getLength() const
Deleted: code/branches/presentation/src/modules/tetris/CMakeLists.txt
===================================================================
--- code/branches/tetris/src/modules/tetris/CMakeLists.txt 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/CMakeLists.txt 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,13 +0,0 @@
-SET_SOURCE_FILES(TETRIS_SRC_FILES
- Tetris.cc
- TetrisCenterpoint.cc
- TetrisStone.cc
-)
-
-ORXONOX_ADD_LIBRARY(tetris
- MODULE
- FIND_HEADER_FILES
- LINK_LIBRARIES
- orxonox
- SOURCE_FILES ${TETRIS_SRC_FILES}
-)
Copied: code/branches/presentation/src/modules/tetris/CMakeLists.txt (from rev 8563, code/branches/tetris/src/modules/tetris/CMakeLists.txt)
===================================================================
--- code/branches/presentation/src/modules/tetris/CMakeLists.txt (rev 0)
+++ code/branches/presentation/src/modules/tetris/CMakeLists.txt 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,13 @@
+SET_SOURCE_FILES(TETRIS_SRC_FILES
+ Tetris.cc
+ TetrisCenterpoint.cc
+ TetrisStone.cc
+)
+
+ORXONOX_ADD_LIBRARY(tetris
+ MODULE
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${TETRIS_SRC_FILES}
+)
Deleted: code/branches/presentation/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/tetris/src/modules/tetris/Tetris.cc 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/Tetris.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,281 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file Tetris.cc
- @brief Implementation of the Tetris class.
-*/
-
-#include "Tetris.h"
-
-#include "core/CoreIncludes.h"
-#include "core/EventIncludes.h"
-#include "core/command/Executor.h"
-
-#include "gamestates/GSLevel.h"
-
-#include "TetrisCenterpoint.h"
-#include "TetrisStone.h"
-#include "infos/PlayerInfo.h"
-
-namespace orxonox
-{
-
- CreateUnloadableFactory(Tetris);
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- */
- Tetris::Tetris(BaseObject* creator) : Deathmatch(creator)
- {
- RegisterObject(Tetris);
-
- this->activeStone_ = NULL;
-
- // Pre-set the timer, but don't start it yet.
- this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Tetris::startStone, this)));
- this->starttimer_.stopTimer();
- }
-
- /**
- @brief
- Destructor. Cleans up, if initialized.
- */
- Tetris::~Tetris()
- {
- if (this->isInitialized())
- this->cleanup();
- }
-
- /**
- @brief
- Cleans up the Gametype.
- */
- void Tetris::cleanup()
- {
-
- }
-
- void Tetris::tick(float dt)
- {
- SUPER(Tetris, tick, dt);
-
- if(this->activeStone_ != NULL)
- {
- std::pair<bool, TetrisStone*> valid = this->isValidMove(this->activeStone_, this->activeStone_->getPosition());
- if(!valid.first)
- {
- this->activeStone_->setVelocity(Vector3::ZERO);
- if(valid.second != NULL)
- {
- Vector3 position = Vector3(this->activeStone_->getPosition().x, valid.second->getPosition().y+this->center_->getStoneSize(), this->activeStone_->getPosition().z);
- this->activeStone_->setPosition(position);
- }
- this->createStone();
- this->startStone();
- }
- }
- }
-
- std::pair<bool, TetrisStone*> Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
- {
- assert(stone);
-
- std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);
-
- if(position.x < this->center_->getStoneSize()/2.0) //!< If the stone touches the left edge of the level
- valid.first = false;
- else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
- valid.first = false;
- else if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level
- {
- valid.first = false;
- stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z));
- }
-
- for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
- {
- if(stone == *it)
- continue;
-
- const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
-
- if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y))
- {
- stone->setVelocity(Vector3::ZERO);
- this->createStone();
- this->startStone();
- valid.first = false;
- return valid;
- }// This case applies if the stones overlap completely
- else if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
- {
- valid.first = false;
- valid.second = *it;
- return valid;
- }// This case applies if the stones overlap partially vertically
- }
-
- return valid;
- }
-
- /**
- @brief
- Starts the Tetris minigame.
- */
- void Tetris::start()
- {
- if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
- {
- // Create the first stone.
- this->createStone();
- }
- else // If no centerpoint was specified, an error is thrown and the level is exited.
- {
- COUT(1) << "Error: No Centerpoint specified." << std::endl;
- GSLevel::startMainMenu();
- return;
- }
-
- // Start the timer. After it has expired the stone is started.
- this->starttimer_.startTimer();
-
- // Set variable to temporarily force the player to spawn.
- bool temp = this->bForceSpawn_;
- this->bForceSpawn_ = true;
-
- // Call start for the parent class.
- Deathmatch::start();
-
- // Reset the variable.
- this->bForceSpawn_ = temp;
- }
-
- /**
- @brief
- Ends the Tetris minigame.
- */
- void Tetris::end()
- {
- this->cleanup();
-
- // Call end for the parent class.
- Deathmatch::end();
- }
-
- /**
- @brief
- Spawns player.
- */
- void Tetris::spawnPlayersIfRequested()
- {
- // Spawn a human player.
- 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);
- }
-
- /**
- @brief
- Spawns the input player.
- @param player
- The player to be spawned.
- */
- void Tetris::spawnPlayer(PlayerInfo* player)
- {
- assert(player);
-
- if(this->player_ != NULL)
- {
- this->player_ = player;
- this->players_[player].state_ = PlayerState::Alive;
- }
- }
-
- /**
- @brief
- Starts the first stone.
- */
- void Tetris::startStone(void)
- {
- if(this->player_ == NULL)
- return;
-
- if(this->activeStone_ != NULL)
- this->player_->stopControl();
-
- // Make the last stone to be created the active stone.
- this->activeStone_ = this->stones_.back();
-
- this->player_->startControl(this->activeStone_);
- this->activeStone_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
- }
-
- /**
- @brief
- Creates a new stone.
- */
- void Tetris::createStone(void)
- {
- // Create a new stone and add it to the list of stones.
- TetrisStone* stone = new TetrisStone(this->center_);
- this->stones_.push_back(stone);
-
- // Apply the stone template to the stone.
- stone->addTemplate(this->center_->getStoneTemplate());
-
- // Attach the stone to the Centerpoint and set the position of the stone to be at the top middle.
- this->center_->attach(stone);
- float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0)*this->center_->getStoneSize();
- float yPos = (this->center_->getHeight()-0.5)*this->center_->getStoneSize();
- stone->setPosition(xPos, yPos, 0.0f);
- stone->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
- {
- return this->player_;
- }
-
- /**
- @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;
- }
-
-}
Copied: code/branches/presentation/src/modules/tetris/Tetris.cc (from rev 8563, code/branches/tetris/src/modules/tetris/Tetris.cc)
===================================================================
--- code/branches/presentation/src/modules/tetris/Tetris.cc (rev 0)
+++ code/branches/presentation/src/modules/tetris/Tetris.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,283 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file Tetris.cc
+ @brief Implementation of the Tetris class.
+*/
+
+#include "Tetris.h"
+
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+
+#include "gamestates/GSLevel.h"
+
+#include "TetrisCenterpoint.h"
+#include "TetrisStone.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+
+ CreateUnloadableFactory(Tetris);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ Tetris::Tetris(BaseObject* creator) : Deathmatch(creator)
+ {
+ RegisterObject(Tetris);
+
+ this->activeStone_ = NULL;
+
+ // Pre-set the timer, but don't start it yet.
+ this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Tetris::startStone, this)));
+ this->starttimer_.stopTimer();
+
+ this->player_ = NULL;
+ }
+
+ /**
+ @brief
+ Destructor. Cleans up, if initialized.
+ */
+ Tetris::~Tetris()
+ {
+ if (this->isInitialized())
+ this->cleanup();
+ }
+
+ /**
+ @brief
+ Cleans up the Gametype.
+ */
+ void Tetris::cleanup()
+ {
+
+ }
+
+ void Tetris::tick(float dt)
+ {
+ SUPER(Tetris, tick, dt);
+
+ if(this->activeStone_ != NULL)
+ {
+ std::pair<bool, TetrisStone*> valid = this->isValidMove(this->activeStone_, this->activeStone_->getPosition());
+ if(!valid.first)
+ {
+ this->activeStone_->setVelocity(Vector3::ZERO);
+ if(valid.second != NULL)
+ {
+ Vector3 position = Vector3(this->activeStone_->getPosition().x, valid.second->getPosition().y+this->center_->getStoneSize(), this->activeStone_->getPosition().z);
+ this->activeStone_->setPosition(position);
+ }
+ this->createStone();
+ this->startStone();
+ }
+ }
+ }
+
+ std::pair<bool, TetrisStone*> Tetris::isValidMove(TetrisStone* stone, const Vector3& position)
+ {
+ assert(stone);
+
+ std::pair<bool, TetrisStone*> valid = std::pair<bool, TetrisStone*>(true, NULL);
+
+ if(position.x < this->center_->getStoneSize()/2.0) //!< If the stone touches the left edge of the level
+ valid.first = false;
+ else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
+ valid.first = false;
+ else if(position.y < this->center_->getStoneSize()/2.0) //!< If the stone has reached the bottom of the level
+ {
+ valid.first = false;
+ stone->setPosition(Vector3(stone->getPosition().x, this->center_->getStoneSize()/2.0, stone->getPosition().z));
+ }
+
+ for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+ {
+ if(stone == *it)
+ continue;
+
+ const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
+
+ if((position.x == currentStonePosition.x) && (position.y == currentStonePosition.y))
+ {
+ stone->setVelocity(Vector3::ZERO);
+ this->createStone();
+ this->startStone();
+ valid.first = false;
+ return valid;
+ }// This case applies if the stones overlap completely
+ else if((position.x == currentStonePosition.x) && (position.y < currentStonePosition.y + this->center_->getStoneSize()))
+ {
+ valid.first = false;
+ valid.second = *it;
+ return valid;
+ }// This case applies if the stones overlap partially vertically
+ }
+
+ return valid;
+ }
+
+ /**
+ @brief
+ Starts the Tetris minigame.
+ */
+ void Tetris::start()
+ {
+ if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
+ {
+ // Create the first stone.
+ this->createStone();
+ }
+ else // If no centerpoint was specified, an error is thrown and the level is exited.
+ {
+ COUT(1) << "Error: No Centerpoint specified." << std::endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+
+ // Start the timer. After it has expired the stone is started.
+ this->starttimer_.startTimer();
+
+ // Set variable to temporarily force the player to spawn.
+ bool temp = this->bForceSpawn_;
+ this->bForceSpawn_ = true;
+
+ // Call start for the parent class.
+ Deathmatch::start();
+
+ // Reset the variable.
+ this->bForceSpawn_ = temp;
+ }
+
+ /**
+ @brief
+ Ends the Tetris minigame.
+ */
+ void Tetris::end()
+ {
+ this->cleanup();
+
+ // Call end for the parent class.
+ Deathmatch::end();
+ }
+
+ /**
+ @brief
+ Spawns player.
+ */
+ void Tetris::spawnPlayersIfRequested()
+ {
+ // Spawn a human player.
+ 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);
+ }
+
+ /**
+ @brief
+ Spawns the input player.
+ @param player
+ The player to be spawned.
+ */
+ void Tetris::spawnPlayer(PlayerInfo* player)
+ {
+ assert(player);
+
+ if(this->player_ == NULL)
+ {
+ this->player_ = player;
+ this->players_[player].state_ = PlayerState::Alive;
+ }
+ }
+
+ /**
+ @brief
+ Starts the first stone.
+ */
+ void Tetris::startStone(void)
+ {
+ if(this->player_ == NULL)
+ return;
+
+ if(this->activeStone_ != NULL)
+ this->player_->stopControl();
+
+ // Make the last stone to be created the active stone.
+ this->activeStone_ = this->stones_.back();
+
+ this->player_->startControl(this->activeStone_);
+ this->activeStone_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
+ }
+
+ /**
+ @brief
+ Creates a new stone.
+ */
+ void Tetris::createStone(void)
+ {
+ // Create a new stone and add it to the list of stones.
+ TetrisStone* stone = new TetrisStone(this->center_);
+ this->stones_.push_back(stone);
+
+ // Apply the stone template to the stone.
+ stone->addTemplate(this->center_->getStoneTemplate());
+
+ // Attach the stone to the Centerpoint and set the position of the stone to be at the top middle.
+ this->center_->attach(stone);
+ float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0)*this->center_->getStoneSize();
+ float yPos = (this->center_->getHeight()-0.5)*this->center_->getStoneSize();
+ stone->setPosition(xPos, yPos, 0.0f);
+ stone->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
+ {
+ return this->player_;
+ }
+
+ /**
+ @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;
+ }
+
+}
Deleted: code/branches/presentation/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/tetris/src/modules/tetris/Tetris.h 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/Tetris.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,92 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file Tetris.h
- @brief Declaration of the Tetris class.
- @ingroup Tetris
-*/
-
-#ifndef _Tetris_H__
-#define _Tetris_H__
-
-#include "tetris/TetrisPrereqs.h"
-
-#include "tools/Timer.h"
-
-#include "gametypes/Deathmatch.h"
-
-namespace orxonox
-{
-
- /**
- @brief
-
- @author
-
- @ingroup Tetris
- */
- class _TetrisExport Tetris : public Deathmatch
- {
- public:
- Tetris(BaseObject* creator); //!< Constructor. Registers and initializes the object.
- virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.
-
- virtual void start(void); //!< Starts the Tetris minigame.
- virtual void end(void); ///!< Ends the Tetris minigame.
-
- virtual void tick(float dt);
-
- virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
-
- void setCenterpoint(TetrisCenterpoint* center);
-
- PlayerInfo* getPlayer(void) const; //!< Get the player.
-
- std::pair<bool, TetrisStone*> isValidMove(TetrisStone* stone, const Vector3& position);
-
- protected:
- virtual void spawnPlayersIfRequested(); //!< Spawns player.
-
- private:
- void startStone(void); //!< Starts with the first stone.
- void createStone(void);
- void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
-
- PlayerInfo* player_;
-
- WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
- std::vector<TetrisStone*> stones_; //!< A list of all stones in play.
- std::vector< std::vector<bool> > grid_;
- TetrisStone* activeStone_;
-
- Timer starttimer_; //!< A timer to delay the start of the game.
- };
-}
-
-#endif /* _Tetris_H__ */
Copied: code/branches/presentation/src/modules/tetris/Tetris.h (from rev 8563, code/branches/tetris/src/modules/tetris/Tetris.h)
===================================================================
--- code/branches/presentation/src/modules/tetris/Tetris.h (rev 0)
+++ code/branches/presentation/src/modules/tetris/Tetris.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,92 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file Tetris.h
+ @brief Declaration of the Tetris class.
+ @ingroup Tetris
+*/
+
+#ifndef _Tetris_H__
+#define _Tetris_H__
+
+#include "tetris/TetrisPrereqs.h"
+
+#include "tools/Timer.h"
+
+#include "gametypes/Deathmatch.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+
+ @author
+
+ @ingroup Tetris
+ */
+ class _TetrisExport Tetris : public Deathmatch
+ {
+ public:
+ Tetris(BaseObject* creator); //!< Constructor. Registers and initializes the object.
+ virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.
+
+ virtual void start(void); //!< Starts the Tetris minigame.
+ virtual void end(void); ///!< Ends the Tetris minigame.
+
+ virtual void tick(float dt);
+
+ virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
+
+ void setCenterpoint(TetrisCenterpoint* center);
+
+ PlayerInfo* getPlayer(void) const; //!< Get the player.
+
+ std::pair<bool, TetrisStone*> isValidMove(TetrisStone* stone, const Vector3& position);
+
+ protected:
+ virtual void spawnPlayersIfRequested(); //!< Spawns player.
+
+ private:
+ void startStone(void); //!< Starts with the first stone.
+ void createStone(void);
+ void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
+
+ PlayerInfo* player_;
+
+ WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
+ std::vector<TetrisStone*> stones_; //!< A list of all stones in play.
+ std::vector< std::vector<bool> > grid_;
+ TetrisStone* activeStone_;
+
+ Timer starttimer_; //!< A timer to delay the start of the game.
+ };
+}
+
+#endif /* _Tetris_H__ */
Deleted: code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc
===================================================================
--- code/branches/tetris/src/modules/tetris/TetrisCenterpoint.cc 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,101 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file TetrisCenterpoint.cc
- @brief Implementation of the TetrisCenterpoint class.
-*/
-
-#include "TetrisCenterpoint.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-#include "Tetris.h"
-
-namespace orxonox
-{
- CreateFactory(TetrisCenterpoint);
-
- /**
- @brief
- Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
- */
- TetrisCenterpoint::TetrisCenterpoint(BaseObject* creator) : StaticEntity(creator)
- {
- RegisterObject(TetrisCenterpoint);
-
- this->width_ = 10;
- this->height_ = 11;
- this->stoneSize_ = 10.0f;
- this->stoneTemplate_ = "";
- this->stoneSpeed_ = 20.0f;
-
- this->checkGametype();
- }
-
- /**
- @brief
- Method to create a TetrisCenterpoint through XML.
- */
- void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
-
- XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
- XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
- XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode);
- XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
- XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
- }
-
- /**
- @brief
- Is called when the gametype has changed.
- */
- void TetrisCenterpoint::changedGametype()
- {
- SUPER(TetrisCenterpoint, changedGametype);
-
- // Check, whether it's still Tetris.
- this->checkGametype();
- }
-
- /**
- @brief
- Checks whether the gametype is Tetris and if it is, sets its centerpoint.
- */
- void TetrisCenterpoint::checkGametype()
- {
- if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
- {
- Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
- tetrisGametype->setCenterpoint(this);
- }
- }
-}
Copied: code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc (from rev 8563, code/branches/tetris/src/modules/tetris/TetrisCenterpoint.cc)
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc (rev 0)
+++ code/branches/presentation/src/modules/tetris/TetrisCenterpoint.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,101 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file TetrisCenterpoint.cc
+ @brief Implementation of the TetrisCenterpoint class.
+*/
+
+#include "TetrisCenterpoint.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "Tetris.h"
+
+namespace orxonox
+{
+ CreateFactory(TetrisCenterpoint);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
+ */
+ TetrisCenterpoint::TetrisCenterpoint(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(TetrisCenterpoint);
+
+ this->width_ = 10;
+ this->height_ = 11;
+ this->stoneSize_ = 10.0f;
+ this->stoneTemplate_ = "";
+ this->stoneSpeed_ = 20.0f;
+
+ this->checkGametype();
+ }
+
+ /**
+ @brief
+ Method to create a TetrisCenterpoint through XML.
+ */
+ void TetrisCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TetrisCenterpoint, XMLPort, xmlelement, mode);
+
+ XMLPortParam(TetrisCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
+ XMLPortParam(TetrisCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
+ XMLPortParam(TetrisCenterpoint, "stoneSize", setStoneSize, getStoneSize, xmlelement, mode);
+ XMLPortParam(TetrisCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
+ XMLPortParam(TetrisCenterpoint, "stoneSpeed", setStoneSpeed, getStoneSpeed, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Is called when the gametype has changed.
+ */
+ void TetrisCenterpoint::changedGametype()
+ {
+ SUPER(TetrisCenterpoint, changedGametype);
+
+ // Check, whether it's still Tetris.
+ this->checkGametype();
+ }
+
+ /**
+ @brief
+ Checks whether the gametype is Tetris and if it is, sets its centerpoint.
+ */
+ void TetrisCenterpoint::checkGametype()
+ {
+ if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
+ {
+ Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+ tetrisGametype->setCenterpoint(this);
+ }
+ }
+}
Deleted: code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h
===================================================================
--- code/branches/tetris/src/modules/tetris/TetrisCenterpoint.h 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,144 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file TetrisCenterpoint.h
- @brief Declaration of the TetrisCenterpoint class.
- @ingroup Tetris
-*/
-
-#ifndef _TetrisCenterpoint_H__
-#define _TetrisCenterpoint_H__
-
-#include "tetris/TetrisPrereqs.h"
-
-#include <string>
-
-#include <util/Math.h>
-
-#include "worldentities/StaticEntity.h"
-
-namespace orxonox
-{
-
- /**
- @brief
-
-
- @author
-
- @ingroup Tetris
- */
- class _TetrisExport TetrisCenterpoint : public StaticEntity
- {
- public:
- TetrisCenterpoint(BaseObject* creator); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
- virtual ~TetrisCenterpoint() {}
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML.
-
- virtual void changedGametype(); //!< Is called when the gametype has changed.
-
- /**
- @brief Set the width of the playing field.
- @param width The width in number of tiles.
- */
- void setWidth(unsigned int width)
- { this->width_ = width; }
- /**
- @brief Get the width of the playing field.
- @return Returns the width in number of tiles.
- */
- unsigned int getWidth(void) const
- { return this->width_; }
-
- /**
- @brief Set the height of the playing field.
- @param height The height in number of tiles.
- */
- void setHeight(unsigned int height)
- { this->height_ = height; }
- /**
- @brief Get the height of the playing field.
- @return Returns the height in number of tiles.
- */
- unsigned int getHeight(void) const
- { return this->height_; }
-
- /**
- @brief Set the size of a single stone.
- @param size The dimensions a stone has in the game world. (A stone is a cube)
- */
- void setStoneSize(float size)
- { this->stoneSize_ = size; }
- /**
- @brief Get the size of a single stone.
- @return Returns the dimensions a stone has in the game world.
- */
- float getStoneSize(void) const
- { return this->stoneSize_; }
-
- /**
- @brief Set the template for the stones.
- @param template 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 speed of the stones.
- @param speed The speed to be set.
- */
- void setStoneSpeed(float speed)
- { this->stoneSpeed_ = speed; }
- /**
- @brief Get the speed of the stones.
- @return Returns the speed a moving stone has.
- */
- float getStoneSpeed(void)
- { return this->stoneSpeed_; }
-
- private:
- void checkGametype(); //!< Checks whether the gametype is Tetris and if it is, sets its centerpoint.
-
- unsigned int width_;
- unsigned int height_;
- float stoneSize_;
- std::string stoneTemplate_;
- float stoneSpeed_;
-
- };
-}
-
-#endif /* _TetrisCenterpoint_H__ */
Copied: code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h (from rev 8563, code/branches/tetris/src/modules/tetris/TetrisCenterpoint.h)
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h (rev 0)
+++ code/branches/presentation/src/modules/tetris/TetrisCenterpoint.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,144 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file TetrisCenterpoint.h
+ @brief Declaration of the TetrisCenterpoint class.
+ @ingroup Tetris
+*/
+
+#ifndef _TetrisCenterpoint_H__
+#define _TetrisCenterpoint_H__
+
+#include "tetris/TetrisPrereqs.h"
+
+#include <string>
+
+#include <util/Math.h>
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+
+
+ @author
+
+ @ingroup Tetris
+ */
+ class _TetrisExport TetrisCenterpoint : public StaticEntity
+ {
+ public:
+ TetrisCenterpoint(BaseObject* creator); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Tetris.
+ virtual ~TetrisCenterpoint() {}
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML.
+
+ virtual void changedGametype(); //!< Is called when the gametype has changed.
+
+ /**
+ @brief Set the width of the playing field.
+ @param width The width in number of tiles.
+ */
+ void setWidth(unsigned int width)
+ { this->width_ = width; }
+ /**
+ @brief Get the width of the playing field.
+ @return Returns the width in number of tiles.
+ */
+ unsigned int getWidth(void) const
+ { return this->width_; }
+
+ /**
+ @brief Set the height of the playing field.
+ @param height The height in number of tiles.
+ */
+ void setHeight(unsigned int height)
+ { this->height_ = height; }
+ /**
+ @brief Get the height of the playing field.
+ @return Returns the height in number of tiles.
+ */
+ unsigned int getHeight(void) const
+ { return this->height_; }
+
+ /**
+ @brief Set the size of a single stone.
+ @param size The dimensions a stone has in the game world. (A stone is a cube)
+ */
+ void setStoneSize(float size)
+ { this->stoneSize_ = size; }
+ /**
+ @brief Get the size of a single stone.
+ @return Returns the dimensions a stone has in the game world.
+ */
+ float getStoneSize(void) const
+ { return this->stoneSize_; }
+
+ /**
+ @brief Set the template for the stones.
+ @param template 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 speed of the stones.
+ @param speed The speed to be set.
+ */
+ void setStoneSpeed(float speed)
+ { this->stoneSpeed_ = speed; }
+ /**
+ @brief Get the speed of the stones.
+ @return Returns the speed a moving stone has.
+ */
+ float getStoneSpeed(void)
+ { return this->stoneSpeed_; }
+
+ private:
+ void checkGametype(); //!< Checks whether the gametype is Tetris and if it is, sets its centerpoint.
+
+ unsigned int width_;
+ unsigned int height_;
+ float stoneSize_;
+ std::string stoneTemplate_;
+ float stoneSpeed_;
+
+ };
+}
+
+#endif /* _TetrisCenterpoint_H__ */
Deleted: code/branches/presentation/src/modules/tetris/TetrisPrereqs.h
===================================================================
--- code/branches/tetris/src/modules/tetris/TetrisPrereqs.h 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/TetrisPrereqs.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,72 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-/**
- at file
- at brief
- Shared library macros, enums, constants and forward declarations for the tetris module
-*/
-
-#ifndef _TetrisPrereqs_H__
-#define _TetrisPrereqs_H__
-
-#include "OrxonoxConfig.h"
-#include "OrxonoxPrereqs.h"
-
-//-----------------------------------------------------------------------
-// Shared library settings
-//-----------------------------------------------------------------------
-
-#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(TETRIS_STATIC_BUILD)
-# ifdef TETRIS_SHARED_BUILD
-# define _TetrisExport __declspec(dllexport)
-# else
-# if defined( __MINGW32__ )
-# define _TetrisExport
-# else
-# define _TetrisExport __declspec(dllimport)
-# endif
-# endif
-#elif defined ( ORXONOX_GCC_VISIBILITY )
-# define _TetrisExport __attribute__ ((visibility("default")))
-#else
-# define _TetrisExport
-#endif
-
-//-----------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------
-
-namespace orxonox
-{
- class Tetris;
- class TetrisCenterpoint;
- class TetrisStone;
-}
-
-#endif /* _TetrisPrereqs_H__ */
Copied: code/branches/presentation/src/modules/tetris/TetrisPrereqs.h (from rev 8563, code/branches/tetris/src/modules/tetris/TetrisPrereqs.h)
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisPrereqs.h (rev 0)
+++ code/branches/presentation/src/modules/tetris/TetrisPrereqs.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,72 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the tetris module
+*/
+
+#ifndef _TetrisPrereqs_H__
+#define _TetrisPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(TETRIS_STATIC_BUILD)
+# ifdef TETRIS_SHARED_BUILD
+# define _TetrisExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _TetrisExport
+# else
+# define _TetrisExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _TetrisExport __attribute__ ((visibility("default")))
+#else
+# define _TetrisExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class Tetris;
+ class TetrisCenterpoint;
+ class TetrisStone;
+}
+
+#endif /* _TetrisPrereqs_H__ */
Deleted: code/branches/presentation/src/modules/tetris/TetrisStone.cc
===================================================================
--- code/branches/tetris/src/modules/tetris/TetrisStone.cc 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/TetrisStone.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,102 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file TetrisStone.cc
- @brief Implementation of the TetrisStone class.
-*/
-
-#include "TetrisStone.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-#include "Tetris.h"
-
-namespace orxonox
-{
- CreateFactory(TetrisStone);
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- */
- TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
- {
- RegisterObject(TetrisStone);
-
- this->size_ = 10.0f;
- this->delay_ = false;
- this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
- }
-
- /**
- @brief
- Overloaded the function to rotate the stone.
- @param value
- A vector whose first component is the angle by which to rotate.
- */
- void TetrisStone::moveFrontBack(const Vector2& value)
- {
- if(value.x < 0)
- {
- this->setVelocity(this->getVelocity()*1.1);
- }
- }
-
- /**
- @brief
- Overloaded the function to steer the stone right and left
- @param value
- A vector whose first component is the direction in which we want to steer the stone.
- */
- void TetrisStone::moveRightLeft(const Vector2& value)
- {
- if(!this->delay_)
- {
- const Vector3& position = this->getPosition();
- Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
- if(!this->tetris_->isValidMove(this, newPos).first)
- return;
-
- //this->previousPosition_ = position;
- this->setPosition(newPos);
- this->delay_ = true;
- this->delayTimer_.startTimer();
- }
- }
-
- /**
- @brief
- Is called when the player changed.
- */
- void TetrisStone::changedPlayer()
- {
- this->setVelocity(0, 0, 0);
- }
-}
Copied: code/branches/presentation/src/modules/tetris/TetrisStone.cc (from rev 8563, code/branches/tetris/src/modules/tetris/TetrisStone.cc)
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisStone.cc (rev 0)
+++ code/branches/presentation/src/modules/tetris/TetrisStone.cc 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,102 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file TetrisStone.cc
+ @brief Implementation of the TetrisStone class.
+*/
+
+#include "TetrisStone.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "Tetris.h"
+
+namespace orxonox
+{
+ CreateFactory(TetrisStone);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ TetrisStone::TetrisStone(BaseObject* creator) : ControllableEntity(creator)
+ {
+ RegisterObject(TetrisStone);
+
+ this->size_ = 10.0f;
+ this->delay_ = false;
+ this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
+ }
+
+ /**
+ @brief
+ Overloaded the function to rotate the stone.
+ @param value
+ A vector whose first component is the angle by which to rotate.
+ */
+ void TetrisStone::moveFrontBack(const Vector2& value)
+ {
+ if(value.x < 0)
+ {
+ this->setVelocity(this->getVelocity()*1.1);
+ }
+ }
+
+ /**
+ @brief
+ Overloaded the function to steer the stone right and left
+ @param value
+ A vector whose first component is the direction in which we want to steer the stone.
+ */
+ void TetrisStone::moveRightLeft(const Vector2& value)
+ {
+ if(!this->delay_)
+ {
+ const Vector3& position = this->getPosition();
+ Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+ if(!this->tetris_->isValidMove(this, newPos).first)
+ return;
+
+ //this->previousPosition_ = position;
+ this->setPosition(newPos);
+ this->delay_ = true;
+ this->delayTimer_.startTimer();
+ }
+ }
+
+ /**
+ @brief
+ Is called when the player changed.
+ */
+ void TetrisStone::changedPlayer()
+ {
+ this->setVelocity(0, 0, 0);
+ }
+}
Deleted: code/branches/presentation/src/modules/tetris/TetrisStone.h
===================================================================
--- code/branches/tetris/src/modules/tetris/TetrisStone.h 2011-05-24 19:07:33 UTC (rev 8563)
+++ code/branches/presentation/src/modules/tetris/TetrisStone.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -1,92 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * ...
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file TetrisStone.h
- @brief Declaration of the TetrisStone class.
- @ingroup Tetris
-*/
-
-#ifndef _TetrisStone_H__
-#define _TetrisStone_H__
-
-#include "tetris/TetrisPrereqs.h"
-
-#include "worldentities/ControllableEntity.h"
-#include "tools/Timer.h"
-
-namespace orxonox
-{
-
- /**
- @brief
-
- @author
-
- @ingroup Tetris
- */
- class _TetrisExport TetrisStone : public ControllableEntity
- {
- public:
- TetrisStone(BaseObject* creator); //!< Constructor. Registers and initializes the object.
- virtual ~TetrisStone() {}
-
- virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
- virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
-
- virtual void changedPlayer(); //!< Is called when the player changed.
-
- /**
- @brief Set the size of the stone.
- @param size The dimensions a stone has in the game world. (A stone is a cube)
- */
- void setSize(float size)
- { this->size_ = size; }
- /**
- @brief Get the size of the stone.
- @return Returns the dimensions a stone has in the game world. (A stone is a cube)
- */
- float getSize(void) const
- { return this->size_; }
-
- void setGame(Tetris* tetris)
- { assert(tetris); tetris_ = tetris; }
-
- private:
- void enableMovement(void)
- { this->delay_ = false; }
-
- float size_; //!< The dimensions a stone has in the game world.
- bool delay_;
- Timer delayTimer_;
-
- Tetris* tetris_;
- };
-}
-
-#endif /* _TetrisStone_H__ */
Copied: code/branches/presentation/src/modules/tetris/TetrisStone.h (from rev 8563, code/branches/tetris/src/modules/tetris/TetrisStone.h)
===================================================================
--- code/branches/presentation/src/modules/tetris/TetrisStone.h (rev 0)
+++ code/branches/presentation/src/modules/tetris/TetrisStone.h 2011-05-24 19:24:39 UTC (rev 8564)
@@ -0,0 +1,92 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * ...
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file TetrisStone.h
+ @brief Declaration of the TetrisStone class.
+ @ingroup Tetris
+*/
+
+#ifndef _TetrisStone_H__
+#define _TetrisStone_H__
+
+#include "tetris/TetrisPrereqs.h"
+
+#include "worldentities/ControllableEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+
+ @author
+
+ @ingroup Tetris
+ */
+ class _TetrisExport TetrisStone : public ControllableEntity
+ {
+ public:
+ TetrisStone(BaseObject* creator); //!< Constructor. Registers and initializes the object.
+ virtual ~TetrisStone() {}
+
+ virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
+ virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
+
+ virtual void changedPlayer(); //!< Is called when the player changed.
+
+ /**
+ @brief Set the size of the stone.
+ @param size The dimensions a stone has in the game world. (A stone is a cube)
+ */
+ void setSize(float size)
+ { this->size_ = size; }
+ /**
+ @brief Get the size of the stone.
+ @return Returns the dimensions a stone has in the game world. (A stone is a cube)
+ */
+ float getSize(void) const
+ { return this->size_; }
+
+ void setGame(Tetris* tetris)
+ { assert(tetris); tetris_ = tetris; }
+
+ private:
+ void enableMovement(void)
+ { this->delay_ = false; }
+
+ float size_; //!< The dimensions a stone has in the game world.
+ bool delay_;
+ Timer delayTimer_;
+
+ Tetris* tetris_;
+ };
+}
+
+#endif /* _TetrisStone_H__ */
More information about the Orxonox-commit
mailing list