|
From: <xs...@us...> - 2006-05-18 20:04:14
|
Revision: 31 Author: xsdwx Date: 2006-05-18 13:04:05 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/perceptioncrash/?rev=31&view=rev Log Message: ----------- Added Paths: ----------- trunk/perceptioncrash/src/PauseState.cpp trunk/perceptioncrash/src/PauseState.hpp trunk/perceptioncrash/src/PlayState.cpp trunk/perceptioncrash/src/PlayState.hpp Added: trunk/perceptioncrash/src/PauseState.cpp =================================================================== --- trunk/perceptioncrash/src/PauseState.cpp (rev 0) +++ trunk/perceptioncrash/src/PauseState.cpp 2006-05-18 20:04:05 UTC (rev 31) @@ -0,0 +1,65 @@ +#include <OGRE/Ogre.h> +#include <OGRE/OgreKeyEvent.h> + +#include "PauseState.hpp" +#include "PlayState.hpp" + +using namespace Ogre; + +PauseState PauseState::mPauseState; + +void +PauseState::enter() +{ + mInputDevice = InputManager::getSingletonPtr()->getInputDevice(); + mRoot = Root::getSingletonPtr(); + + mViewport = mRoot->getAutoCreatedWindow()->getViewport(0); + mViewport->setBackgroundColour(ColourValue(0.0, 1.0, 0.0)); +} + +void +PauseState::exit() +{ +} + +void +PauseState::pause() +{ +} + +void +PauseState::resume() +{ +} + +void +PauseState::keyClicked(KeyEvent* e) +{ +} + +void +PauseState::keyPressed(KeyEvent* e) +{ + if (e->getKey() == KC_P) + { + popState(); + } +} + +void +PauseState::keyReleased(KeyEvent* e) +{ +} + +bool +PauseState::frameStarted(const FrameEvent& evt) +{ + return true; +} + +bool +PauseState::frameEnded(const FrameEvent& evt) +{ + return true; +} Added: trunk/perceptioncrash/src/PauseState.hpp =================================================================== --- trunk/perceptioncrash/src/PauseState.hpp (rev 0) +++ trunk/perceptioncrash/src/PauseState.hpp 2006-05-18 20:04:05 UTC (rev 31) @@ -0,0 +1,38 @@ +#ifndef PC_PAUSE_STATE_HPP +#define PC_PAUSE_STATE_HPP + +#include <OGRE/Ogre.h> + +#include "GameState.hpp" + +class PauseState : public GameState +{ +public: + void enter(); + void exit(); + + void pause(); + void resume(); + + void keyClicked(Ogre::KeyEvent* e); + void keyPressed(Ogre::KeyEvent* e); + void keyReleased(Ogre::KeyEvent* e); + bool frameStarted(const Ogre::FrameEvent& evt); + bool frameEnded(const Ogre::FrameEvent& evt); + + static PauseState* getInstance() { return &mPauseState; } + +protected: + PauseState() { } + + Ogre::Root *mRoot; + Ogre::SceneManager* mSceneMgr; + Ogre::Viewport* mViewport; + Ogre::InputReader* mInputDevice; + Ogre::Camera* mCamera; + +private: + static PauseState mPauseState; +}; + +#endif /* PC_PAUSE_STATE_HPP */ Added: trunk/perceptioncrash/src/PlayState.cpp =================================================================== --- trunk/perceptioncrash/src/PlayState.cpp (rev 0) +++ trunk/perceptioncrash/src/PlayState.cpp 2006-05-18 20:04:05 UTC (rev 31) @@ -0,0 +1,77 @@ +#include <OGRE/Ogre.h> +#include <OGRE/OgreKeyEvent.h> + +#include "PlayState.hpp" +#include "IntroState.hpp" +#include "PauseState.hpp" + +using namespace Ogre; + +PlayState PlayState::mPlayState; + +void +PlayState::enter() +{ + mInputDevice = InputManager::getSingletonPtr()->getInputDevice(); + mRoot = Root::getSingletonPtr(); + + mSceneMgr = mRoot->createSceneManager(ST_GENERIC); + mCamera = mSceneMgr->createCamera("PlayCamera"); + mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera); + mViewport->setBackgroundColour(ColourValue(0.3, 0.3, 0.3)); +} + +void +PlayState::exit() +{ + mSceneMgr->clearScene(); + mSceneMgr->destroyAllCameras(); + mRoot->getAutoCreatedWindow()->removeAllViewports(); +} + +void +PlayState::pause() +{ +} + +void +PlayState::resume() +{ + mViewport->setBackgroundColour(ColourValue(0.3, 0.3, 0.3)); +} + +void +PlayState::keyClicked(KeyEvent* e) +{ +} + +void +PlayState::keyPressed(KeyEvent* e) +{ + if (e->getKey() == KC_P) + { + pushState(PauseState::getInstance()); + } + + if (e->getKey() == KC_ESCAPE) + { + changeState(IntroState::getInstance()); + } +} + +void +PlayState::keyReleased(KeyEvent* e) +{ +} + +bool +PlayState::frameStarted(const FrameEvent& evt) +{ + return true; +} + +bool +PlayState::frameEnded(const FrameEvent& evt) +{ + return true; +} Added: trunk/perceptioncrash/src/PlayState.hpp =================================================================== --- trunk/perceptioncrash/src/PlayState.hpp (rev 0) +++ trunk/perceptioncrash/src/PlayState.hpp 2006-05-18 20:04:05 UTC (rev 31) @@ -0,0 +1,39 @@ +#ifndef PC_PLAY_STATE_HPP +#define PC_PLAY_STATE_HPP + +#include <OGRE/Ogre.h> + +#include "GameState.hpp" + +class PlayState : public GameState +{ +public: + void enter(); + void exit(); + + void pause(); + void resume(); + + void keyClicked(Ogre::KeyEvent* e); + void keyPressed(Ogre::KeyEvent* e); + void keyReleased(Ogre::KeyEvent* e); + bool frameStarted(const Ogre::FrameEvent& evt); + bool frameEnded(const Ogre::FrameEvent& evt); + + static PlayState* getInstance() + { return &mPlayState; } + +protected: + PlayState() { } + + Ogre::Root *mRoot; + Ogre::SceneManager* mSceneMgr; + Ogre::Viewport* mViewport; + Ogre::InputReader* mInputDevice; + Ogre::Camera* mCamera; + +private: + static PlayState mPlayState; +}; + +#endif /* PC_PLAY_STATE_HPP */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |