Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8895 for code/branches


Ignore:
Timestamp:
Oct 13, 2011, 8:59:27 PM (13 years ago)
Author:
jo
Message:

Added end to pong gametype. Unfortunately the hud isn't consistent at the game's end at the moment.

Location:
code/branches/gamecontent/src/modules/pong
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamecontent/src/modules/pong/Pong.cc

    r8858 r8895  
    3939
    4040#include "gamestates/GSLevel.h"
     41#include "chat/ChatManager.h"
    4142
    4243#include "PongCenterpoint.h"
     
    4546#include "PongBot.h"
    4647#include "PongAI.h"
    47 
    4848namespace orxonox
    4949{
     
    7575        // Set the type of Bots for this particular Gametype.
    7676        this->botclass_ = Class(PongBot);
     77        this->scoreLimit_ = 3; //TODO: 21
    7778    }
    7879
     
    280281        }
    281282
     283        // If a palyer gets 21 points, he won the game -> end of game
     284       
     285        PlayerInfo* player1 = this->getLeftPlayer();
     286        PlayerInfo* player2 = this->getRightPlayer();
     287        if(player1==NULL||player2==NULL) return; //safety
     288        if(this->getScore(player1) >= scoreLimit_)
     289        {
     290            std::string name1=player1->getName();
     291            std::string message(name1 + " has won!");
     292            ChatManager::message(message);
     293            this->end();
     294        }
     295        else if(this->getScore(player2) >= scoreLimit_)
     296        {
     297             std::string name2=player2->getName();
     298             std::string message2(name2 + " has won!");
     299             ChatManager::message(message2);
     300             this->end();
     301        }
    282302        // Restart the timer to start the ball.
    283303        this->starttimer_.startTimer();
     304
    284305    }
    285306
  • code/branches/gamecontent/src/modules/pong/Pong.h

    r8351 r8895  
    9494            WeakPtr<PongBall> ball_; //!< The Pong ball.
    9595            WeakPtr<PongBat> bat_[2]; //!< The two bats.
    96             Timer starttimer_; //!< A timer to delay the start of the game.
     96            Timer starttimer_; //!< A timer to delay the start of the game.
     97            int scoreLimit_; //!< If a player scored that much points, the game is ended.
    9798    };
    9899}
  • code/branches/gamecontent/src/modules/pong/PongAI.h

    r8108 r8895  
    8080            void delayedMove(); //!< Is called, when a delayed move takes effect.
    8181
    82             PongBall* ball_; //!< A pointer to the ball.
     82            WeakPtr<PongBall> ball_; //!< A weak pointer to the ball.
    8383            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
    8484            float ballEndPosition_; //!< The calculated end position of the ball.
Note: See TracChangeset for help on using the changeset viewer.