Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2005, 11:52:15 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelloader/src/world_entities/player.cc

    r3604 r3605  
    1616*/
    1717
     18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PLAYER
     19
    1820#include "player.h"
     21
    1922#include "stdincl.h"
    2023//#include "collision.h"
    2124#include "objModel.h"
     25#include "list.h"
     26#include "weapon.h"
     27#include "track_manager.h"
    2228
    2329using namespace std;
     
    3137Player::Player(bool isFree) : WorldEntity(isFree)
    3238{
    33 
    3439  this->model = new OBJModel("../data/models/reaplow.obj");
    35   /*
    36   objectList = glGenLists(1);
    37   glNewList (objectList, GL_COMPILE);
    38 
    39   glBegin(GL_TRIANGLES);
    40   glColor3f(1,1,1);
    41   glVertex3f(0,0,0.5);
    42   glVertex3f(-0.5,0,-1);
    43   glVertex3f(0.5,0,-1);
    44 
    45   glVertex3f(0,0,0.5);
    46   glVertex3f(0,0.5,-1);
    47   glVertex3f(0,-0.5,-1);
    48   glEnd();
    49    
    50   glBegin(GL_QUADS);
    51   glColor3f(0,0,1);
    52   glVertex3f(0.5,0.5,-1);
    53   glVertex3f(0.5,-0.5,-1);
    54   glVertex3f(-0.5,-0.5,-1);
    55   glVertex3f(-0.5,0.5,-1);
    56   glEnd();
    57  
    58   glEndList ();
    59   */
    60 }
     40  this->weapons = new tList<Weapon>();
     41  this->activeWeapon = NULL;
     42
     43  travelSpeed = 15.0;
     44  velocity = Vector();
     45  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
     46  bFire = false;
     47  acceleration = 10.0;
     48}
     49
     50/**
     51   \brief destructs the player, deletes alocated memory
     52*/
     53Player::~Player ()
     54{
     55  Weapon* w = this->weapons->enumerate();
     56  while( w != NULL)
     57    {
     58      delete w;
     59      w = this->weapons->nextElement();
     60    }
     61  delete this->weapons;
     62 
     63  //delete this->velocity;
     64}
     65
    6166
    6267/**
     
    102107
    103108/**
    104    \brief destructs the player
    105 */
    106 Player::~Player ()
    107 {
    108   delete this->model;
    109 }
     109   \brief adds a weapon to the weapon list of player
     110   \param weapon to add
     111*/
     112void Player::addWeapon(Weapon* weapon)
     113{
     114  this->weapons->add(weapon);
     115}
     116
     117
     118/**
     119   \brief removes a weapon from the player
     120   \param weapon to remove
     121*/
     122void Player::removeWeapon(Weapon* weapon)
     123{
     124  this->weapons->remove(weapon);
     125}
     126
    110127
    111128/**
     
    114131void Player::postSpawn ()
    115132{
    116   travelSpeed = 15.0;
    117   velocity = Vector();
    118   bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    119   bFire = false;
    120   acceleration = 10.0;
    121133  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    122134}
    123135
    124 /**
    125    \brief the function called for each passing timeSnap
    126    \param time The timespan passed since last update
    127 */
    128 void Player::tick (float time)
    129 {
    130   // movement
    131   this->move (time);
    132 }
     136
     137/**
     138   \brief the action occuring if the player left the game
     139*/
     140void Player::leftWorld ()
     141{}
     142
     143
    133144
    134145/**
     
    137148   \param loc ??
    138149*/
    139 void Player::hit (WorldEntity* weapon, Vector loc)
    140 {
    141 }
    142 
    143 /**
    144    \brief action that happens when the player is destroyed.
    145 */
    146 void Player::destroy ()
    147 {
    148 }
     150void Player::hit (WorldEntity* weapon, Vector* loc)
     151{
     152}
     153
    149154
    150155/**
     
    158163}
    159164
    160 /**
    161    \brief The connection to the command node
    162    \param cmd the Command unit from witch to map
    163 
    164    here the commands are mapped to the players movement/weaponary
    165 */
    166 void Player::command (Command* cmd)
    167 {
    168   //printf("Player|recieved command [%s]\n", cmd->cmd);
    169   if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;
    170   else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;
    171   else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;
    172   else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;
    173   else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;
    174 }
    175165
    176166/**
     
    180170{
    181171  glMatrixMode(GL_MODELVIEW);
    182   glLoadIdentity();
     172  glPushMatrix();
    183173  float matrix[4][4];
    184174 
     
    191181  glMultMatrixf((float*)matrix);
    192182 
    193   glMatrixMode(GL_MODELVIEW);
    194183  this->model->draw();
    195   // glCallList(objectList);
    196 }
    197 
    198 
    199 /*PN
    200   void Player::getLookat(Location* locbuf)
    201   {
    202   *locbuf = *getLocation();
    203   //locbuf->dist += 5.0;
    204   }
    205 */
    206 
    207 /**
    208    \brief the action occuring if the player left the game
    209 */
    210 void Player::leftWorld ()
    211 {
    212 }
     184  glPopMatrix();
     185}
     186
     187
     188/**
     189   \brief the function called for each passing timeSnap
     190   \param time The timespan passed since last update
     191*/
     192void Player::tick (float time)
     193{
     194  // player controlled movement
     195  this->move (time);
     196  // weapon system manipulation
     197  this->fire();
     198}
     199
    213200
    214201/**
     
    220207  Vector accel(0.0, 0.0, 0.0);
    221208  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    222   //Placement *pos = getPlacement();
    223209 
    224210  /* calculate the direction in which the craft is heading  */
     
    228214  //orthDirection = orthDirection.cross (direction);
    229215
    230   if( bUp) { accel = accel+(direction*acceleration); }
    231   if( bDown) { accel = accel-(direction*acceleration); }
    232   if( bLeft ) { accel = accel - (orthDirection*acceleration); }
    233   if( bRight ) { accel = accel + (orthDirection*acceleration); }
    234   if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */}
    235   if( bDescend) {/* FIXME */} /* \todo up and down player movement */
    236 
    237   //Location* l = getLocation();
    238  
    239   // r(t) = r(0) + v(0)*t + 1/2*a*t^2
    240   // r = position
    241   // v = velocity
    242   // a = acceleration
    243 
    244   /* this the base-speed of the player: determines how fast and how the player follows the track*/
    245   //l->dist = l->dist + travelSpeed * time;
    246  
    247   Vector* shift = new Vector (this->travelSpeed * time, 0, 0);
    248   this->shiftCoor (shift);
    249  
    250   /* this updates the player position on the track - user interaction */
    251   //l->pos = l->pos + accel*time;
     216  if( this->bUp && this->getRelCoor().x < 20)
     217    accel = accel+(direction*acceleration);
     218  if( this->bDown && this->getRelCoor().x > -5)
     219    accel = accel-(direction*acceleration);
     220  if( this->bLeft &&  TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2)
     221    accel = accel - (orthDirection*acceleration);
     222  if( this->bRight &&  TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
     223    accel = accel + (orthDirection*acceleration);
     224  if( this->bAscend )
     225  if( this->bDescend) {/* FIXME */} /* \todo up and down player movement */
     226
    252227  Vector move = accel * time;
    253228  this->shiftCoor (&move);
    254229}
     230
     231
     232/**
     233   \brief weapon manipulation by the player
     234*/
     235void Player::fire()
     236{
     237  if(this->bFire)
     238    {
     239      if(this->activeWeapon != NULL)
     240        this->activeWeapon->fire();
     241    }
     242  if(this->bWeaponChange)
     243    {
     244      Weapon* w = this->weapons->enumerate();
     245      this->activeWeapon = this->weapons->nextElement(this->activeWeapon);
     246    }
     247}
     248
     249
     250/**
     251   \brief The connection to the command node
     252   \param cmd the Command unit from witch to map
     253
     254   here the commands are mapped to the players movement/weaponary
     255*/
     256void Player::command (Command* cmd)
     257{
     258  PRINTF(3)("recieved command [%s]\n", cmd->cmd);
     259  if( !strcmp( cmd->cmd, "up")) this->bUp = !cmd->bUp;
     260  else if( !strcmp( cmd->cmd, "down")) this->bDown = !cmd->bUp;
     261  else if( !strcmp( cmd->cmd, "left")) this->bLeft = !cmd->bUp;
     262  else if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp;
     263  else if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp;
     264  else if( !strcmp( cmd->cmd, "mode")) this->bWeaponChange = !cmd->bUp;
     265}
Note: See TracChangeset for help on using the changeset viewer.