Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 6, 2006, 12:47:01 AM (18 years ago)
Author:
patrick
Message:

trunk: game rules definitions added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r7037 r7039  
    2020#include "factory.h"
    2121
     22#include "render2D/billboard.h"
     23#include "state.h"
     24
    2225
    2326using namespace std;
     
    3740  this->bLocalPlayerDead = false;
    3841  this->deathTimeout = 10.0f;     // 5 seconds
     42  this->deathScreen = new Billboard();
     43  this->deathScreen->setSize(State::getResX(), State::getResY());
    3944
    4045  if( root != NULL)
     
    5964  LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills)
    6065      .describe("sets the maximal kills for winning condition");
     66
     67  LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen)
     68      .describe("sets the death screen image");
     69
    6170}
     71
     72
     73
     74void MultiplayerTeamDeathmatch::setDeathScreen(const char* imageName)
     75{
     76  if( this->deathScreen)
     77    this->deathScreen->setTexture(imageName);
     78}
     79
    6280
    6381
     
    6785 */
    6886void MultiplayerTeamDeathmatch::onPlayerSpawn(Player* player)
    69 {}
     87{
     88  this->bLocalPlayerDead = true;
     89}
    7090
    7191
     
    7595 */
    7696void MultiplayerTeamDeathmatch::onPlayerDeath(Player* player)
    77 {}
     97{
     98  this->localPlayer = player;
     99  this->bLocalPlayerDead = true;
     100}
    78101
    79102
     
    84107void MultiplayerTeamDeathmatch::tick(float dt)
    85108{
     109  this->checkGameRules();
    86110
     111  // is the local player dead and inactive
     112  if( unlikely(this->bLocalPlayerDead))
     113  {
     114    this->timeout += dt;
     115
     116    // long enough dead?
     117    if( dt >= this->deathTimeout)
     118    {
     119      this->timeout = 0.0f;
     120
     121      // respawn
     122    }
     123  }
    87124}
    88125
     
    92129 */
    93130void MultiplayerTeamDeathmatch::draw()
    94 {}
     131{
     132  if( unlikely( this->bLocalPlayerDead))
     133  {
     134
     135  }
     136}
    95137
    96138
     
    99141 */
    100142void MultiplayerTeamDeathmatch::checkGameRules()
    101 {}
     143{
     144  //
     145  // check for max killing count
     146  if( this->teamAKills >= this->maxKills)
     147  {
     148    // team A winns
     149  }
     150  else if( this->teamBKills >= this->maxKills)
     151  {
     152    // team B winns
     153  }
     154}
    102155
    103156
Note: See TracChangeset for help on using the changeset viewer.