Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2008, 6:14:31 PM (16 years ago)
Author:
rgrieder
Message:
  • merged all changes in the input branch into this one
  • moved Tickable to core (would have created circular library dependencies)
  • exported OrxListener to a separate file, soon to be deleted
changed
, &&, XOR back to or, and, xor because I found the necessary include file for VC++
  • created abortRequest() in Orxonox.cc to call for a smooth end of the game (an alternative would be to make tick() return a boolean, like it is with frameStarted())
Location:
code/branches/network/src/orxonox/tools
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/tools/OrxListener.cc

    r916 r917  
    3131#include "objects/NPC.h"
    3232#include "audio/AudioManager.h"
     33#include "Orxonox.h"
    3334#include "OrxListener.h"
    3435
    3536namespace orxonox
    3637{
    37   OrxListener::OrxListener(audio::AudioManager*  auMan, gameMode mode)
     38  OrxListener::OrxListener(OIS::Keyboard *keyboard, audio::AudioManager*  auMan, gameMode mode)
    3839  {
     40    keyboard_ = keyboard;
    3941    mode_=mode;
    4042    auMan_ = auMan;
     
    4547    auMan_->update();
    4648    updateAI();
     49
     50    keyboard_->capture();
     51    if (keyboard_->isKeyDown(OIS::KC_ESCAPE))
     52      Orxonox::getSingleton()->abortRequest();
    4753  }
    4854
  • code/branches/network/src/orxonox/tools/OrxListener.h

    r916 r917  
    3434#define _OrxListener_H__
    3535
     36#include <OIS/OISPrereqs.h>
     37
    3638#include "../OrxonoxPrereqs.h"
    3739#include "audio/AudioPrereqs.h"
    3840#include "Orxonox.h"
    39 #include "objects/Tickable.h"
     41#include "core/Tickable.h"
    4042
    4143namespace orxonox
     
    4446  {
    4547    public:
    46       OrxListener(audio::AudioManager*  auMan, gameMode mode);
     48      OrxListener(OIS::Keyboard *keyboard, audio::AudioManager*  auMan, gameMode mode);
    4749
    4850      void tick(float dt);
     
    5254      gameMode mode_;
    5355      audio::AudioManager* auMan_;
     56      OIS::Keyboard *keyboard_;
    5457  };
    5558}
  • code/branches/network/src/orxonox/tools/Timer.cc

    r871 r917  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28#include "OrxonoxStableHeaders.h"
     29
    130#include "core/CoreIncludes.h"
    231#include "Timer.h"
     
    1746        this->time_ = 0;
    1847    }
     48
     49    /**
     50        @brief Updates the timer before the frames are rendered.
     51    */
     52    void TimerBase::tick(float dt)
     53    {
     54        if (this->bActive_)
     55        {
     56            // If active: Decrease the timer by the duration of the last frame
     57            this->time_ -= dt;
     58
     59            if (this->time_ <= 0)
     60            {
     61                // It's time to call the function
     62                if (this->bLoop_)
     63                    // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
     64                    this->time_ += this->interval_;
     65                else
     66                    this->stopTimer(); // Stop the timer if we don't want to loop
     67
     68                this->run();
     69            }
     70        }
     71    }
     72
    1973}
  • code/branches/network/src/orxonox/tools/Timer.h

    r871 r917  
    5858#define _Timer_H__
    5959
    60 #include <OgreFrameListener.h>
    6160#include "../OrxonoxPrereqs.h"
     61#include "core/Tickable.h"
    6262
    6363namespace orxonox
    6464{
    6565    //! TimerBase is the parent of the Timer class.
    66     class _OrxonoxExport TimerBase : public OrxonoxClass
     66    class _OrxonoxExport TimerBase : public Tickable
    6767    {
    68         friend class TimerFrameListener;
    69 
    7068        public:
    7169            TimerBase();
     
    8381            /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */
    8482            inline bool isActive() const { return this->bActive_; }
     83
     84            void tick(float dt);
    8585
    8686        protected:
     
    145145    };
    146146
    147     //! The TimerFrameListener manages all Timers in the game.
    148     class TimerFrameListener : public Ogre::FrameListener
    149     {
    150         private:
    151             /** @brief Gets called before a frame gets rendered. */
    152             bool frameStarted(const Ogre::FrameEvent &evt)
    153             {
    154                 // Iterate through all Timers
    155                 for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; )
    156                 {
    157                     if (it->isActive())
    158                     {
    159                         // If active: Decrease the timer by the duration of the last frame
    160                         it->time_ -= evt.timeSinceLastFrame;
    161 
    162                         if (it->time_ <= 0)
    163                         {
    164                             // It's time to call the function
    165                             if (it->bLoop_)
    166                                 it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
    167                             else
    168                                 it->stopTimer(); // Stop the timer if we don't want to loop
    169 
    170                             (it++)->run();
    171                         }
    172                         else
    173                             ++it;
    174                     }
    175                     else
    176                         ++it;
    177                 }
    178 
    179                 return FrameListener::frameStarted(evt);
    180             }
    181     };
    182147}
    183148
Note: See TracChangeset for help on using the changeset viewer.