Changeset 12212
- Timestamp:
- Mar 21, 2019, 2:19:16 PM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/data/tcl/orxokart_highscores.txt
r12194 r12212 19 19 Name: 0:25:40s 20 20 Name: 1:27:11s 21 Name: 0:29:74s -
code/branches/OrxoBlox_FS19/src/modules/CMakeLists.txt
r12194 r12212 53 53 ADD_SUBDIRECTORY(orxokart) 54 54 ADD_SUBDIRECTORY(wagnis) 55 ADD_SUBDIRECTORY(OrxoBlox) -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
r12210 r12212 1 SET_SOURCE_FILES( PONG_SRC_FILES2 BUILD_UNIT PongBuildUnit.cc3 Pong.cc4 PongAI.cc5 PongBall.cc6 PongBat.cc7 PongBot.cc8 PongCenterpoint.cc9 PongScore.cc1 SET_SOURCE_FILES(OrxoBlox_FS19_SRC_FILES 2 BUILD_UNIT OrxoBloxBuildUnit.cc 3 OrxoBlox.cc 4 OrxoBloxAI.cc 5 OrxoBloxBall.cc 6 OrxoBloxBat.cc 7 OrxoBloxBot.cc 8 OrxoBloxCenterpoint.cc 9 OrxoBloxScore.cc 10 10 END_BUILD_UNIT 11 11 ) 12 12 13 ORXONOX_ADD_LIBRARY( pong13 ORXONOX_ADD_LIBRARY(OrxoBlox_FS19 14 14 PLUGIN 15 15 FIND_HEADER_FILES … … 17 17 orxonox 18 18 overlays 19 SOURCE_FILES ${ PONG_SRC_FILES}19 SOURCE_FILES ${OrxoBlox_FS19_SRC_FILES} 20 20 ) -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
r12210 r12212 28 28 29 29 /** 30 @file Pong.cc31 @brief Implementation of the Pongclass.30 @file OrxoBlox.cc 31 @brief Implementation of the OrxoBlox class. 32 32 */ 33 33 34 #include " Pong.h"34 #include "OrxoBlox.h" 35 35 36 36 #include "core/CoreIncludes.h" … … 42 42 #include "chat/ChatManager.h" 43 43 44 #include "PongCenterpoint.h" 45 #include "PongBall.h" 46 #include "PongBat.h" 47 #include "PongBot.h" 48 #include "PongAI.h" 49 44 #include "OrxoBloxCenterpoint.h" 45 #include "OrxoBloxBall.h" 46 #include "OrxoBloxBat.h" 47 #include "OrxoBloxBot.h" 48 #include "OrxoBloxAI.h" 50 49 namespace orxonox 51 50 { 52 51 // Events to allow to react to scoring of a player, in the level-file. 53 CreateEventName( PongCenterpoint, right);54 CreateEventName( PongCenterpoint, left);55 56 RegisterUnloadableClass( Pong);52 CreateEventName(OrxoBloxCenterpoint, right); 53 CreateEventName(OrxoBloxCenterpoint, left); 54 55 RegisterUnloadableClass(OrxoBlox); 57 56 58 57 /** … … 60 59 Constructor. Registers and initializes the object. 61 60 */ 62 Pong::Pong(Context* context) : Deathmatch(context)63 { 64 RegisterObject( Pong);61 OrxoBlox::OrxoBlox(Context* context) : Deathmatch(context) 62 { 63 RegisterObject(OrxoBlox); 65 64 66 65 this->center_ = nullptr; … … 69 68 this->bat_[1] = nullptr; 70 69 71 this->setHUDTemplate(" PongHUD");70 this->setHUDTemplate("OrxoBloxHUD"); 72 71 73 72 // Pre-set the timer, but don't start it yet. 74 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(& Pong::startBall, this)));73 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&OrxoBlox::startBall, this))); 75 74 this->starttimer_.stopTimer(); 76 75 77 76 // Set the type of Bots for this particular Gametype. 78 this->botclass_ = Class( PongBot);77 this->botclass_ = Class(OrxoBloxBot); 79 78 80 79 this->scoreLimit_ = 10; … … 86 85 Destructor. Cleans up, if initialized. 87 86 */ 88 Pong::~Pong()87 OrxoBlox::~OrxoBlox() 89 88 { 90 89 if (this->isInitialized()) … … 92 91 } 93 92 94 void Pong::setConfigValues()93 void OrxoBlox::setConfigValues() 95 94 { 96 95 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins."); … … 101 100 Cleans up the Gametype by destroying the ball and the bats. 102 101 */ 103 void Pong::cleanup()102 void OrxoBlox::cleanup() 104 103 { 105 104 if (this->ball_ != nullptr) // Destroy the ball, if present. … … 123 122 /** 124 123 @brief 125 Starts the Pongminigame.126 */ 127 void Pong::start()128 { 129 if (this->center_ != nullptr) // There needs to be a PongCenterpoint, i.e. the area the game takes place.124 Starts the OrxoBlox minigame. 125 */ 126 void OrxoBlox::start() 127 { 128 if (this->center_ != nullptr) // There needs to be a OrxoBloxCenterpoint, i.e. the area the game takes place. 130 129 { 131 130 if (this->ball_ == nullptr) // If there is no ball, create a new ball. 132 131 { 133 this->ball_ = new PongBall(this->center_->getContext());132 this->ball_ = new OrxoBloxBall(this->center_->getContext()); 134 133 // Apply the template for the ball specified by the centerpoint. 135 134 this->ball_->addTemplate(this->center_->getBalltemplate()); … … 145 144 146 145 // If one of the bats is missing, create it. Apply the template for the bats as specified in the centerpoint. 147 for (WeakPtr<orxonox:: PongBat>& bat : this->bat_)146 for (WeakPtr<orxonox::OrxoBloxBat>& bat : this->bat_) 148 147 { 149 148 if (bat == nullptr) 150 149 { 151 bat = new PongBat(this->center_->getContext());150 bat = new OrxoBloxBat(this->center_->getContext()); 152 151 bat->addTemplate(this->center_->getBattemplate()); 153 152 } … … 173 172 else // If no centerpoint was specified, an error is thrown and the level is exited. 174 173 { 175 orxout(internal_error) << " Pong: No Centerpoint specified." << endl;174 orxout(internal_error) << "OrxoBlox: No Centerpoint specified." << endl; 176 175 GSLevel::startMainMenu(); 177 176 return; … … 194 193 /** 195 194 @brief 196 Ends the Pongminigame.197 */ 198 void Pong::end()195 Ends the OrxoBlox minigame. 196 */ 197 void OrxoBlox::end() 199 198 { 200 199 this->cleanup(); … … 208 207 Spawns players, and fills the rest up with bots. 209 208 */ 210 void Pong::spawnPlayersIfRequested()209 void OrxoBlox::spawnPlayersIfRequested() 211 210 { 212 211 // first spawn human players to assign always the left bat to the player in singleplayer … … 226 225 The player to be spawned. 227 226 */ 228 void Pong::spawnPlayer(PlayerInfo* player)227 void OrxoBlox::spawnPlayer(PlayerInfo* player) 229 228 { 230 229 assert(player); … … 247 246 248 247 // If the player is an AI, it receives a pointer to the ball. 249 if (player->getController() != nullptr && player->getController()->isA(Class( PongAI)))250 { 251 PongAI* ai = orxonox_cast<PongAI*>(player->getController());252 ai->set PongBall(this->ball_);248 if (player->getController() != nullptr && player->getController()->isA(Class(OrxoBloxAI))) 249 { 250 OrxoBloxAI* ai = orxonox_cast<OrxoBloxAI*>(player->getController()); 251 ai->setOrxoBloxBall(this->ball_); 253 252 } 254 253 } … … 258 257 Is called when the player scored. 259 258 */ 260 void Pong::playerScored(PlayerInfo* player, int score)259 void OrxoBlox::playerScored(PlayerInfo* player, int score) 261 260 { 262 261 Deathmatch::playerScored(player, score); … … 266 265 // Fire an event for the player that has scored, to be able to react to it in the level, e.g. by displaying fireworks. 267 266 if (player == this->getRightPlayer()) 268 this->center_->fireEvent(FireEventName( PongCenterpoint, right));267 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, right)); 269 268 else if (player == this->getLeftPlayer()) 270 this->center_->fireEvent(FireEventName( PongCenterpoint, left));269 this->center_->fireEvent(FireEventName(OrxoBloxCenterpoint, left)); 271 270 272 271 // Also announce, that the player has scored. … … 312 311 Starts the ball with some default speed. 313 312 */ 314 void Pong::startBall()313 void OrxoBlox::startBall() 315 314 { 316 315 if (this->ball_ != nullptr && this->center_ != nullptr) … … 324 323 Returns a pointer to the player playing on the left. If there is no left player, nullptr is returned. 325 324 */ 326 PlayerInfo* Pong::getLeftPlayer() const325 PlayerInfo* OrxoBlox::getLeftPlayer() const 327 326 { 328 327 if (this->bat_[0] != nullptr) … … 338 337 Returns a pointer to the player playing on the right. If there is no right player, nullptr is returned. 339 338 */ 340 PlayerInfo* Pong::getRightPlayer() const339 PlayerInfo* OrxoBlox::getRightPlayer() const 341 340 { 342 341 if (this->bat_[1] != nullptr) -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
r12210 r12212 41 41 42 42 #include "gametypes/Deathmatch.h" 43 #include " PongCenterpoint.h"43 #include "OrxoBloxCenterpoint.h" 44 44 45 45 namespace orxonox … … 48 48 /** 49 49 @brief 50 Implements a Pong minigame (<a href="http://en.wikipedia.org/wiki/Pong">Wikipedia::Pong</a>).51 It connects the different entities present in a game of Pong.50 Implements a OrxoBlox minigame (<a href="http://en.wikipedia.org/wiki/OrxoBlox">Wikipedia::OrxoBlox</a>). 51 It connects the different entities present in a game of OrxoBlox. 52 52 53 - The @ref orxonox:: PongCenterpoint "PongCenterpoint" is the playing field for the Pong minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::PongBat "PongBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.<br />54 The Pong class redistributes the important parameters defined in @ref orxonox::PongCenterpoint "PongCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::PongBall "PongBall" and the @ref orxonox::PongBat "PongBats".<br />55 The @ref orxonox:: PongCenterpoint "PongCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" <em>Pong</em>.56 - The @ref orxonox:: PongBall "PongBall" is the ball both players play with. The @ref orxonox::PongBall "PongBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::PongBat "PongBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player).57 - The two @ref orxonox:: PongBat "PongBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::PongBat "PongBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats.53 - The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" is the playing field for the OrxoBlox minigame, it allows for configuration of the minigame, e.g. by setting the size of the playing field, or the length of the @ref orxonox::OrxoBloxBat "OrxoBloxBats". The playing field is always in the x,y-plane, the x-axis being the horizontal and the z-axis being the vertical axis.<br /> 54 The OrxoBlox class redistributes the important parameters defined in @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" to the other entities, that need to know them, e.g. the @ref orxonox::OrxoBloxBall "OrxoBloxBall" and the @ref orxonox::OrxoBloxBat "OrxoBloxBats".<br /> 55 The @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint" needs to exist in a level with the @ref orxonox::Gametype "Gametype" <em>OrxoBlox</em>. 56 - The @ref orxonox::OrxoBloxBall "OrxoBloxBall" is the ball both players play with. The @ref orxonox::OrxoBloxBall "OrxoBloxBall" both implements the movement of the ball, as well as the influence of the boundaries and consequently, also the bouncing (off the upper and lower delimiters, and as off the @ref orxonox::OrxoBloxBat "OrxoBloxBats") of the ball and the effects of the failure of a player to catch the ball (i.e. the scoring of the other player). 57 - The two @ref orxonox::OrxoBloxBat "OrxoBloxBats" are the entities through which the players can actively participate in the game, by controlling them. The @ref orxonox::OrxoBloxBat "OrxoBloxBat" class manages the movement (and restrictions thereof) and the influence of the players on the bats. 58 58 59 59 @author 60 60 Fabian 'x3n' Landau 61 61 62 @ingroup Pong62 @ingroup OrxoBlox 63 63 */ 64 class _ PongExport Pong: public Deathmatch64 class _OrxoBloxExport OrxoBlox : public Deathmatch 65 65 { 66 66 public: 67 Pong(Context* context); //!< Constructor. Registers and initializes the object.68 virtual ~ Pong(); //!< Destructor. Cleans up, if initialized.67 OrxoBlox(Context* context); //!< Constructor. Registers and initializes the object. 68 virtual ~OrxoBlox(); //!< Destructor. Cleans up, if initialized. 69 69 70 virtual void start() override; //!< Starts the Pongminigame.71 virtual void end() override; ///!< Ends the Pongminigame.70 virtual void start() override; //!< Starts the OrxoBlox minigame. 71 virtual void end() override; ///!< Ends the OrxoBlox minigame. 72 72 73 73 virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player. … … 76 76 77 77 /** 78 @brief Set the PongCenterpoint (the playing field).79 @param center A pointer to the PongCenterpoint to be set.78 @brief Set the OrxoBloxCenterpoint (the playing field). 79 @param center A pointer to the OrxoBloxCenterpoint to be set. 80 80 */ 81 void setCenterpoint( PongCenterpoint* center)81 void setCenterpoint(OrxoBloxCenterpoint* center) 82 82 { this->center_ = center; } 83 83 void setConfigValues(); //!< Makes scoreLimit configurable. … … 92 92 void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats. 93 93 94 WeakPtr< PongCenterpoint> center_; //!< The playing field.95 WeakPtr< PongBall> ball_; //!< The Pongball.96 WeakPtr< PongBat> bat_[2]; //!< The two bats.94 WeakPtr<OrxoBloxCenterpoint> center_; //!< The playing field. 95 WeakPtr<OrxoBloxBall> ball_; //!< The OrxoBlox ball. 96 WeakPtr<OrxoBloxBat> bat_[2]; //!< The two bats. 97 97 Timer starttimer_; //!< A timer to delay the start of the game. 98 98 int scoreLimit_; //!< If a player scored that much points, the game is ended. … … 100 100 } 101 101 102 #endif /* _ Pong_H__ */102 #endif /* _OrxoBlox_H__ */ -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
r12210 r12212 1 2 //TODO: Sounds (all the sounds are still from the pong module...)3 //TODO: Blocks (the Ball-Block comunication is based on how the blocks are implemented)4 //TODO: The bottom boundary/ the Ball collecter5 //TODO: Ability to shoot the ball (the ball is still constructed like the pong ball)6 7 1 /* 8 2 * ORXONOX - the hottest 3D action shooter ever to exist … … 45 39 #include "gametypes/Gametype.h" 46 40 47 #include "OrxoBloxB locks.h"41 #include "OrxoBloxBat.h" 48 42 49 43 #include "sound/WorldSound.h" … … 67 61 this->speed_ = 0; 68 62 this->accelerationFactor_ = 1.0f; 69 this->b lock_ = nullptr;70 this->bDeleteB lock_ = false;71 this->b lockID_ = new unsigned int[100];72 for (int i = 0; i < 100; i++) { 73 this->blockID_[i] = OBJECTID_UNKNOWN;74 } 63 this->bat_ = nullptr; 64 this->bDeleteBats_ = false; 65 this->batID_ = new unsigned int[2]; 66 this->batID_[0] = OBJECTID_UNKNOWN; 67 this->batID_[1] = OBJECTID_UNKNOWN; 68 this->relMercyOffset_ = 0.05f; 75 69 76 70 this->registerVariables(); … … 102 96 if (this->isInitialized()) 103 97 { 104 if (this->bDeleteB lock_)105 delete[] this->b lock_;106 107 delete[] this->b lockID_;98 if (this->bDeleteBats_) 99 delete[] this->bat_; 100 101 delete[] this->batID_; 108 102 } 109 103 } … … 126 120 registerVariable( this->fieldWidth_ ); 127 121 registerVariable( this->fieldHeight_ ); 128 registerVariable( this->b locklength_ );122 registerVariable( this->batlength_ ); 129 123 registerVariable( this->speed_ ); 130 registerVariable( this->blockID_[0] ); 131 registerVariable( this->blockID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBlock) ); 124 registerVariable( this->relMercyOffset_ ); 125 registerVariable( this->batID_[0] ); 126 registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBats) ); 132 127 } 133 128 … … 135 130 @brief 136 131 Is called every tick. 137 Handles the movement of the ball and its interaction with the boundaries and b locks.132 Handles the movement of the ball and its interaction with the boundaries and bats. 138 133 @param dt 139 134 The time since the last tick. … … 148 143 Vector3 acceleration = this->getAcceleration(); 149 144 150 // If the ball has hit the boundaries on either the right side or the left 151 if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2) 152 { 153 defBoundarySound_->play(); //play boundary sound 154 // Its velocity in x-direction is inverted (i.e. it bounces off). 155 velocity.x = -velocity.x; 156 // And its position is set as to not overstep the boundary it has just crossed. 157 if (position.x > this->fieldWidth_ / 2) 158 position.x = this->fieldWidth_ / 2; 159 if (position.x < -this->fieldWidth_ / 2) 160 position.x = -this->fieldWidth_ / 2; 161 162 this->fireEvent(); 163 } 164 165 // If the ball has hit the boundary on the top 166 if (position.z > this->fieldHeight_ / 2) 145 // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters). 146 if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2) 167 147 { 168 148 defBoundarySound_->play(); //play boundary sound … … 170 150 velocity.z = -velocity.z; 171 151 // And its position is set as to not overstep the boundary it has just crossed. 172 position.z = this->fieldHeight_ / 2; 152 if (position.z > this->fieldHeight_ / 2) 153 position.z = this->fieldHeight_ / 2; 154 if (position.z < -this->fieldHeight_ / 2) 155 position.z = -this->fieldHeight_ / 2; 173 156 174 157 this->fireEvent(); 175 158 } 176 159 177 // If the ball has crossed the bottom boundary 178 if (position.z < -this->fieldHeight_ / 2) 179 { 180 //TODO: Ball Collector 160 // If the ball has crossed the left or right boundary of the playing field (i.e. a player has just scored, if the bat isn't there to parry). 161 if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2) 162 { 163 float distance = 0; 164 165 if (this->bat_ != nullptr) // If there are bats. 166 { 167 // If the right boundary has been crossed. 168 if (position.x > this->fieldWidth_ / 2 && this->bat_[1] != nullptr) 169 { 170 // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%) 171 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2); 172 if (fabs(distance) <= 1) // If the bat is there to parry. 173 { 174 defBatSound_->play(); //play bat sound 175 // Set the ball to be exactly at the boundary. 176 position.x = this->fieldWidth_ / 2; 177 // Invert its velocity in x-direction (i.e. it bounces off). 178 velocity.x = -velocity.x; 179 // Adjust the velocity in the z-direction, depending on where the ball hit the bat. 180 velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_; 181 acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1; 182 183 this->fireEvent(); 184 } 185 // If the left player scores. 186 else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 187 { 188 defScoreSound_->play();//play score sound 189 if (this->getGametype() && this->bat_[0]) 190 { 191 this->getGametype()->playerScored(this->bat_[0]->getPlayer()); 192 return; 193 } 194 } 195 } 196 // If the left boundary has been crossed. 197 else if (position.x < -this->fieldWidth_ / 2 && this->bat_[0] != nullptr) 198 { 199 // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%) 200 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2); 201 if (fabs(distance) <= 1) // If the bat is there to parry. 202 { 203 defBatSound_->play(); //play bat sound 204 // Set the ball to be exactly at the boundary. 205 position.x = -this->fieldWidth_ / 2; 206 // Invert its velocity in x-direction (i.e. it bounces off). 207 velocity.x = -velocity.x; 208 // Adjust the velocity in the z-direction, depending on where the ball hit the bat. 209 velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_; 210 acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1; 211 212 this->fireEvent(); 213 } 214 // If the right player scores. 215 else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 216 { 217 defScoreSound_->play();//play score sound 218 if (this->getGametype() && this->bat_[1]) 219 { 220 this->getGametype()->playerScored(this->bat_[1]->getPlayer()); 221 return; 222 } 223 } 224 } 225 } 181 226 } 182 227 … … 215 260 /** 216 261 @brief 217 Set the b locks for the ball.262 Set the bats for the ball. 218 263 @param bats 219 An array (of size n (n=#Blocks) of weak pointers, to be set as the new blocks.220 */ 221 void OrxoBloxBall::setB lock(WeakPtr<OrxoBloxBlock>* block, int n)222 { 223 if (this->bDeleteB lock_) // If there are already some blocks, delete them.224 { 225 delete[] this->b lock_;226 this->bDeleteB lock_ = false;227 } 228 229 this->b lock_ = block;264 An array (of size 2) of weak pointers, to be set as the new bats. 265 */ 266 void OrxoBloxBall::setBats(WeakPtr<OrxoBloxBat>* bats) 267 { 268 if (this->bDeleteBats_) // If there are already some bats, delete them. 269 { 270 delete[] this->bat_; 271 this->bDeleteBats_ = false; 272 } 273 274 this->bat_ = bats; 230 275 // Also store their object IDs, for synchronization. 231 for (int i = 0; i < n; i++) { 232 this->blockID_[i] = this->block_[i]->getObjectID(); 233 } 234 } 235 236 /** 237 @brief 238 Get the blocks over the network. 239 */ 240 void OrxoBloxBall::applyBlock(int n) 241 { 242 // Make space for the blocks, if they don't exist, yet. 243 if (this->block_ == nullptr) 244 { 245 this->block_ = new WeakPtr<OrxoBloxBlock>[n]; 246 this->bDeleteBlock_ = true; 247 } 248 249 for (int i = 0; i < n; i++) { 250 if (this->blockID_[i] != OBJECTID_UNKNOWN) 251 this->bat_[i] = orxonox_cast<OrxoBloxBlock*>(Synchronisable::getSynchronisable(this->blockID_[i])); 252 } 253 } 254 255 void OrxoBloxBall::setDefScoreSound(const std::string &pongSound) 276 this->batID_[0] = this->bat_[0]->getObjectID(); 277 this->batID_[1] = this->bat_[1]->getObjectID(); 278 } 279 280 /** 281 @brief 282 Get the bats over the network. 283 */ 284 void OrxoBloxBall::applyBats() 285 { 286 // Make space for the bats, if they don't exist, yet. 287 if (this->bat_ == nullptr) 288 { 289 this->bat_ = new WeakPtr<OrxoBloxBat>[2]; 290 this->bDeleteBats_ = true; 291 } 292 293 if (this->batID_[0] != OBJECTID_UNKNOWN) 294 this->bat_[0] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[0])); 295 if (this->batID_[1] != OBJECTID_UNKNOWN) 296 this->bat_[1] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[1])); 297 } 298 299 void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound) 256 300 { 257 301 if( defScoreSound_ ) 258 defScoreSound_->setSource( pongSound);302 defScoreSound_->setSource(OrxoBloxSound); 259 303 else 260 304 assert(0); // This should never happen, because soundpointer is only available on master … … 270 314 } 271 315 272 void OrxoBloxBall::setDefBatSound(const std::string & pongSound)316 void OrxoBloxBall::setDefBatSound(const std::string &OrxoBloxSound) 273 317 { 274 318 if( defBatSound_ ) 275 defBatSound_->setSource( pongSound);319 defBatSound_->setSource(OrxoBloxSound); 276 320 else 277 321 assert(0); // This should never happen, because soundpointer is only available on master … … 287 331 } 288 332 289 void OrxoBloxBall::setDefBoundarySound(const std::string & pongSound)333 void OrxoBloxBall::setDefBoundarySound(const std::string &OrxoBloxSound) 290 334 { 291 335 if( defBoundarySound_ ) 292 defBoundarySound_->setSource( pongSound);336 defBoundarySound_->setSource(OrxoBloxSound); 293 337 else 294 338 assert(0); // This should never happen, because soundpointer is only available on master -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
r12210 r12212 50 50 This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox". 51 51 52 It is responsible for both the movement of the ball in the x, y-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBlocks "OrxoBloxBlocks". Or more precisely, it makes the ball bounce off then left and right delimiters of the playing field, it makes the ball bounce off the blocks, damages them and also detects when it reaches the lower boundand takes appropriate measures.52 It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBat "OrxoBloxBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures. 53 53 54 54 @author … … 76 76 /** 77 77 @brief Get the dimensions of the playing field. 78 @param dimension A vector with the width as the first and height as the second 78 @param dimension A vector with the width as the first and height as the second component. 79 79 */ 80 80 void setFieldDimension(const Vector2& dimension) … … 82 82 /** 83 83 @brief Get the dimensions of the playing field. 84 @return Returns a vector with the width as the first and height as the second 84 @return Returns a vector with the width as the first and height as the second component. 85 85 */ 86 86 Vector2 getFieldDimension() const … … 109 109 110 110 /** 111 @brief Set the length of the b locks.112 @param batlength The length of the b locks (in x-direction) as percentage of the heightof the playing field.111 @brief Set the length of the bats. 112 @param batlength The length of the bats (in z-direction) as percentage of the height of the playing field. 113 113 */ 114 void setB lockLength(float blocklength)115 { this->b locklength_ = blocklength; }114 void setBatLength(float batlength) 115 { this->batlength_ = batlength; } 116 116 /** 117 @brief Get the length of the b locks.118 @return Returns the length of the b locks as percentage of the height of the playingfield.117 @brief Get the length of the bats. 118 @return Returns the length of the bats (in z-direction) as percentage of the height of the playing field. 119 119 */ 120 float getB lockLength() const121 { return this->blocklength_; }120 float getBatLength() const 121 { return this->batlength_; } 122 122 123 void setB lock(WeakPtr<OrxoBloxBlock>* block); //!< Set the blocks for the ball.124 void applyB lock(); //!< Get the blockover the network.123 void setBats(WeakPtr<OrxoBloxBat>* bats); //!< Set the bats for the ball. 124 void applyBats(); //!< Get the bats over the network. 125 125 126 126 static const float MAX_REL_Z_VELOCITY; … … 138 138 float fieldWidth_; //!< The width of the playing field. 139 139 float fieldHeight_; //!< The height of the playing field. 140 float speedX_; //!< The speed (in x-direction) of the ball. 141 float speedY_; //!< The speed (in y-direction) of the ball. 140 float speed_; //!< The speed (in x-direction) of the ball. 142 141 float accelerationFactor_; //!< The acceleration factor of the ball. 143 float blocklength_; //!< The length of the bats (in z-direction) as percentage of the height of the playing field. 144 WeakPtr<OrxoBloxBlock>* block_; //!< An array with the blocks. 145 bool bDeleteBlock_; //!< Bool, to keep track, of whether this->block_ exists or not. 146 unsigned int* blockID_; //!< The object IDs of the blocks, to be able to synchronize them over the network. 142 float batlength_; //!< The length of the bats (in z-direction) as percentage of the height of the playing field. 143 WeakPtr<OrxoBloxBat>* bat_; //!< An array with the two bats. 144 bool bDeleteBats_; //!< Bool, to keep track, of whether this->bat_ exists or not. 145 unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network. 146 float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have. 147 147 WorldSound* defScoreSound_; 148 148 WorldSound* defBatSound_; -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
r12210 r12212 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( PONG_STATIC_BUILD)46 # ifdef PONG_SHARED_BUILD47 # define _ PongExport __declspec(dllexport)45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(OrxoBlox_STATIC_BUILD) 46 # ifdef OrxoBlox_SHARED_BUILD 47 # define _OrxoBloxExport __declspec(dllexport) 48 48 # else 49 49 # if defined( __MINGW32__ ) 50 # define _ PongExport50 # define _OrxoBloxExport 51 51 # else 52 # define _ PongExport __declspec(dllimport)52 # define _OrxoBloxExport __declspec(dllimport) 53 53 # endif 54 54 # endif 55 # define _ PongPrivate55 # define _OrxoBloxPrivate 56 56 #elif defined (ORXONOX_GCC_VISIBILITY) 57 # define _ PongExport __attribute__ ((visibility("default")))58 # define _ PongPrivate __attribute__ ((visibility("hidden")))57 # define _OrxoBloxExport __attribute__ ((visibility("default"))) 58 # define _OrxoBloxPrivate __attribute__ ((visibility("hidden"))) 59 59 #else 60 # define _ PongExport61 # define _ PongPrivate60 # define _OrxoBloxExport 61 # define _OrxoBloxPrivate 62 62 #endif 63 63 … … 68 68 namespace orxonox 69 69 { 70 class Pong;71 class PongAI;72 class PongBall;73 class PongBat;74 class PongBot;75 class PongCenterpoint;76 class PongScore;70 class OrxoBlox; 71 class OrxoBloxAI; 72 class OrxoBloxBall; 73 class OrxoBloxBat; 74 class OrxoBloxBot; 75 class OrxoBloxCenterpoint; 76 class OrxoBloxScore; 77 77 } 78 78 79 #endif /* _ PongPrereqs_H__ */79 #endif /* _OrxoBloxPrereqs_H__ */
Note: See TracChangeset
for help on using the changeset viewer.