zenilib: zenilib/jni/external/zenilib/zeni_rest/Zeni/Gamestate.hxx Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gamestate.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ZENI_GAMESTATE_HXX
19 #define ZENI_GAMESTATE_HXX
20
21 #include <Zeni/Gamestate.h>
22
23 namespace Zeni {
24
25 const bool & Gamestate_Base::is_pausable() const {
26 return m_pausable;
27 }
28
29 void Gamestate_Base::set_pausable(const bool &pausable_) {
30 m_pausable = pausable_;
31 }
32
33 void Gamestate_Base::increment() {
34 ++m_count;
35 }
36
37 void Gamestate_Base::decrement() {
38 if(!--m_count)
39 delete this;
40 }
41
42 Gamestate::Gamestate()
43 : m_state(0)
44 {
45 }
46
47 Gamestate::Gamestate(Gamestate_Base * const &state)
48 : m_state(state)
49 {
50 assert(m_state);
51
52 if(m_state)
53 m_state->increment();
54 }
55
56 Gamestate::Gamestate(const Gamestate &state)
57 : m_state(state.m_state)
58 {
59 if(m_state)
60 m_state->increment();
61 }
62
63 Gamestate & Gamestate::operator=(const Gamestate &state) {
64 if(state.m_state)
65 state.m_state->increment();
66
67 if(m_state)
68 m_state->decrement();
69
70 m_state = state.m_state;
71
72 return *this;
73 }
74
75 #ifdef ANDROID
76 void Gamestate::on_event(android_app &app, const AInputEvent &event) {
77 m_state->on_event(app, event);
78 }
79 #else
80 void Gamestate::on_event(const SDL_Event &event) {
81 m_state->on_event(event);
82 }
83 #endif
84
85 void Gamestate::perform_logic() {
86 m_state->perform_logic();
87 }
88
89 void Gamestate::prerender() {
90 m_state->prerender();
91 }
92
93 void Gamestate::render() {
94 m_state->render();
95 }
96
97 void Gamestate::on_push() {
98 m_state->on_push();
99 }
100
101 void Gamestate::on_cover() {
102 m_state->on_cover();
103 }
104
105 void Gamestate::on_uncover() {
106 m_state->on_uncover();
107 }
108
109 void Gamestate::on_pop() {
110 m_state->on_pop();
111 }
112
113 const bool & Gamestate::is_pausable() const {
114 return m_state->is_pausable();
115 }
116
117 Gamestate_Base & Gamestate::get() {
118 return *m_state;
119 }
120
121 }
122
123 #endif
Zeni::Gamestate::operator=
Gamestate & operator=(const Gamestate &state)
Definition: Gamestate.hxx:63
Zeni::Gamestate::on_event
void on_event(const SDL_Event &event)
Definition: Gamestate.hxx:80
Zeni::Gamestate_Base::set_pausable
void set_pausable(const bool &pausable_)
Definition: Gamestate.hxx:29
Zeni::Gamestate_Base::render
virtual void render()
Then render. Called by Game as part of the main gameloop.
Definition: Gamestate.cpp:1093
Zeni::Gamestate::on_pop
void on_pop()
Definition: Gamestate.hxx:109
Zeni::Gamestate_Base::on_pop
virtual void on_pop()
Called when the Gamestate is popped off the stack in Game.
Definition: Gamestate.cpp:1110
Zeni::Gamestate::on_push
void on_push()
Definition: Gamestate.hxx:97
assert
#define assert(x)
Definition: SDL_malloc.c:1234
Zeni::Gamestate::Gamestate
Gamestate()
Definition: Gamestate.hxx:42
Zeni::Gamestate_Base::prerender
virtual void prerender()
No actual rendering, but any logic strictly necessary for rendering.
Definition: Gamestate.h:103
android_app
Definition: android_native_app_glue.h:111
Zeni::Gamestate::is_pausable
const bool & is_pausable() const
Definition: Gamestate.hxx:113
Zeni::Gamestate::on_uncover
void on_uncover()
Definition: Gamestate.hxx:105
Zeni::Gamestate
A smartpointer for a Gamestate_Base.
Definition: Gamestate.h:169
Zeni::Gamestate_Base::is_pausable
const bool & is_pausable() const
Definition: Gamestate.hxx:25
Zeni::Gamestate::render
void render()
Definition: Gamestate.hxx:93
Zeni::Gamestate_Base::on_event
virtual void on_event(const SDL_Event &event)
First check for events. Called by Game as part of the main gameloop.
Definition: Gamestate.cpp:36
Zeni::Gamestate_Base::on_uncover
virtual void on_uncover()
Called when a Gamestate is popped off Game, making this Gamestate on top.
Definition: Gamestate.cpp:1107
Zeni::Gamestate_Base
The base class for all gamestates.
Definition: Gamestate.h:82
Zeni::Gamestate::perform_logic
void perform_logic()
Definition: Gamestate.hxx:85
Gamestate.h
Zeni::Gamestate::get
Gamestate_Base & get()
Definition: Gamestate.hxx:117
SDL_Event
General event structure.
Definition: SDL_events.h:495
Zeni::Gamestate_Base::on_push
virtual void on_push()
Called when the Gamestate is pushed onto the stack in Game.
Definition: Gamestate.cpp:1101
Zeni::Gamestate::on_cover
void on_cover()
Definition: Gamestate.hxx:101
Zeni::Gamestate::prerender
void prerender()
Definition: Gamestate.hxx:89
Zeni::Gamestate_Base::perform_logic
virtual void perform_logic()
Then perform logic. Called by Game as part of the main gameloop.
Definition: Gamestate.h:101
Zeni::Gamestate_Base::on_cover
virtual void on_cover()
Called when a Gamestate is pushed on top of this Gamestate in Game.
Definition: Gamestate.cpp:1104
event
cl_event event
Definition: glew.h:3556