Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 17, 2005, 4:46:19 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: shooting works, with interval-handling :)
now after 2 hours of war of the worlds, 5 hours coding…. for some 3-4 hours sleep, until i can't stop thinking about a better way to implement the rest of the WeaponSystem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc

    r4880 r4881  
    1616   2005-07-15: Benjamin Grauer: restructurating the entire Class
    1717*/
     18
     19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1820
    1921#include "weapon.h"
     
    7476  this->maxCharge = 0.0;
    7577
    76   this->active = false;
     78  this->active = true;
    7779  this->projectile = NULL;
    7880}
     
    104106void Weapon::requestAction(WeaponAction action)
    105107{
     108  printf("next action will be %d\n", action);
    106109  this->requestedAction = action;
    107110}
    108111
    109 bool Weapon::execute(WeaponAction action)
    110 {
    111   this->stateDuration = this->times[action] + this->stateDuration;
    112 
    113   switch (action)
     112bool Weapon::execute()
     113{
     114  this->stateDuration = this->times[this->requestedAction] + this->stateDuration;
     115
     116  PRINT(3)("executing action %d\n", this->requestedAction);
     117
     118  switch (this->requestedAction)
    114119  {
    115120    case WA_SHOOT:
     
    129134      break;
    130135  }
     136  this->requestedAction = WA_NONE;
    131137}
    132138
     
    146152void Weapon::fire()
    147153{
    148 
    149154}
    150155
     
    174179void Weapon::tick(float dt)
    175180{
     181  // setting up the timing properties
     182  this->stateDuration -= dt;
     183
    176184  if (this->isActive())
    177185  {
    178     this->stateDuration -= dt;
    179 
    180     if (this->stateDuration < 0.0)
    181       this->execute(this->requestedAction);
     186    if (this->stateDuration <= 0.0 && this->requestedAction != WA_NONE)
     187      this->execute();
    182188  }
    183189  else
Note: See TracChangeset for help on using the changeset viewer.