| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #ifndef SAMPLE_H_
- #define SAMPLE_H_
- #include "gameplay.h"
- using namespace gameplay;
- /**
- * Base class for all of the samples.
- *
- * The goal is to provide an interface that matches the Game class.
- * This way you can easily copy the code from your sample into a game.
- */
- class Sample
- {
- friend class SamplesGame;
- public:
- static const Game::State& UNINITIALIZED;
- static const Game::State& RUNNING;
- static const Game::State& PAUSED;
- static const Game::ClearFlags& CLEAR_COLOR;
- static const Game::ClearFlags& CLEAR_DEPTH;
- static const Game::ClearFlags& CLEAR_STENCIL;
- static const Game::ClearFlags& CLEAR_COLOR_DEPTH;
- static const Game::ClearFlags& CLEAR_COLOR_STENCIL;
- static const Game::ClearFlags& CLEAR_DEPTH_STENCIL;
- static const Game::ClearFlags& CLEAR_COLOR_DEPTH_STENCIL;
- static bool isVsync();
- static void setVsync(bool enable);
- static long getAbsoluteTime();
- static long getGameTime();
- Game::State getState() const;
- int run();
- void pause();
- void resume();
- void exit();
- void frame();
- unsigned int getFrameRate() const;
- const Rectangle& getViewport() const;
- void setViewport(const Rectangle& viewport);
- unsigned int getWidth() const;
- unsigned int getHeight() const;
- float getAspectRatio() const;
- void clear(Game::ClearFlags flags, const Vector4& clearColor, float clearDepth, int clearStencil);
- void clear(Game::ClearFlags flags, float red, float green, float blue, float alpha, float clearDepth, int clearStencil);
- AudioController* getAudioController() const;
- AnimationController* getAnimationController() const;
- PhysicsController* getPhysicsController() const;
- ScriptController* getScriptController() const;
- void displayKeyboard(bool display);
- virtual void keyEvent(Keyboard::KeyEvent evt, int key);
- virtual void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
- virtual bool mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
- bool hasMouse();
- bool isMouseCaptured();
- void setMouseCaptured(bool captured);
- void setMultiTouch(bool enabled);
- bool isMultiTouch() const;
- void getAccelerometerValues(float* pitch, float* roll);
- void schedule(long timeOffset, TimeListener* timeListener, void* cookie = 0);
- void enableScriptCamera(bool enable);
- void setScriptCameraSpeed(float normal, float fast);
- bool isGestureSupported(Gesture::GestureEvent evt);
- void registerGesture(Gesture::GestureEvent evt);
- void unregisterGesture(Gesture::GestureEvent evt);
- bool isGestureRegistered(Gesture::GestureEvent evt);
- virtual void gestureSwipeEvent(int x, int y, int direction);
- virtual void gesturePinchEvent(int x, int y, float scale);
- virtual void gestureTapEvent(int x, int y);
- virtual void gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex = 0);
- unsigned int getGamepadCount() const;
- Gamepad* getGamepad(unsigned int index, bool preferPhysical = true) const;
- protected:
- Sample();
- virtual ~Sample();
- virtual void initialize() = 0;
- virtual void finalize() = 0;
- virtual void update(float elapsedTime) = 0;
- virtual void render(float elapsedTime) = 0;
- static void drawFrameRate(Font* font, const Vector4& color, unsigned int x, unsigned int y, unsigned int fps);
- private:
- Sample(const Sample&);
- Sample& operator=(const Sample&);
- };
- #endif
|