forked from StaticHex/cs354r_p2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseApplication.h
199 lines (172 loc) · 5.94 KB
/
BaseApplication.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
-----------------------------------------------------------------------------
Filename: BaseApplication.h
-----------------------------------------------------------------------------
This source file is part of the
___ __ __ _ _ _
/___\__ _ _ __ ___ / / /\ \ (_) | _(_)
// // _` | '__/ _ \ \ \/ \/ / | |/ / |
/ \_// (_| | | | __/ \ /\ /| | <| |
\___/ \__, |_| \___| \/ \/ |_|_|\_\_|
|___/
Tutorial Framework (for Ogre 1.9)
http://www.ogre3d.org/wiki/
-----------------------------------------------------------------------------
*/
#ifndef __BaseApplication_h_
#define __BaseApplication_h_
#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>
#include <SDL.h>
#include <SDL_mixer.h>
#include <vector>
#include <SDL_net.h>
#include<time.h>
#include <iostream>
#include <fstream>
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
# include <OIS/OISEvents.h>
# include <OIS/OISInputManager.h>
# include <OIS/OISKeyboard.h>
# include <OIS/OISMouse.h>
# include <OGRE/SdkTrays.h>
# include <OGRE/SdkCameraMan.h>
#else
# include <OISEvents.h>
# include <OISInputManager.h>
# include <OISKeyboard.h>
# include <OISMouse.h>
# include <SdkTrays.h>
# include <SdkCameraMan.h>
#endif
//#include <CEGUI/RendererModules/Ogre/Renderer.h>
//#include <CEGUI/CEGUI.h>
#include "Sphere.h"
#include "Block.h"
#include "Room.h"
#include "Paddle.h"
#include "Physics.h"
#include "SGUI.h"
#ifdef OGRE_STATIC_LIB
# define OGRE_STATIC_GL
# if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
# define OGRE_STATIC_Direct3D9
// D3D10 will only work on vista, so be careful about statically linking
# if OGRE_USE_D3D10
# define OGRE_STATIC_Direct3D10
# endif
# endif
# define OGRE_STATIC_BSPSceneManager
# define OGRE_STATIC_ParticleFX
# define OGRE_STATIC_CgProgramManager
# ifdef OGRE_USE_PCZ
# define OGRE_STATIC_PCZSceneManager
# define OGRE_STATIC_OctreeZone
# else
# define OGRE_STATIC_OctreeSceneManager
# endif
# include "OgreStaticPluginLoader.h"
#endif
//---------------------------------------------------------------------------
class BaseApplication : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener, OgreBites::SdkTrayListener
{
public:
BaseApplication(void);
virtual ~BaseApplication(void);
virtual void go(void);
// Socket stuff
bool isServer;
bool connectionOpened;
bool sceneCreated;
TCPsocket server;
TCPsocket client;
clock_t lastUpdate;
// GUI
SGUI* mGUI;
// SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS
Room* emptyRoom;
std::vector<Sphere*> balls;
std::vector<Block*> blocks;
Physics* engine;
Paddle* paddle1;
Paddle* paddle2;
double lastTime = time(0);
double newTime = 0.0;
double t = 0.0;
double dt = 1 / 60.0;
int score = 0;
bool multiplayer;
// Sounds
bool soundOn = true;
Mix_Chunk* explosion;
Mix_Chunk* woosh;
Mix_Chunk* metal_sound;
Mix_Chunk* brick_sound;
Mix_Chunk* stone_sound;
Mix_Chunk* wood_sound;
Mix_Chunk* paper_sound;
Mix_Music* bgm;
enum Type { paper, wood, stone, brick, metal };
int p1lives = 10;
int p2lives = 10;
int lastHit = 0;
// SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS // SCENE OBJECTS
protected:
virtual bool setup();
virtual bool configure(void);
virtual void chooseSceneManager(void);
virtual void createCamera(void);
virtual void createFrameListener(void);
virtual void createScene(void) = 0; // Override me!
virtual void destroyScene(void);
virtual void createViewports(void);
virtual void setupResources(void);
virtual void createResourceListener(void);
virtual void loadResources(void);
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
virtual void updateClient();
virtual bool keyPressed(const OIS::KeyEvent &arg);
virtual bool keyReleased(const OIS::KeyEvent &arg);
virtual bool mouseMoved(const OIS::MouseEvent &arg);
virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
//bool quit(const CEGUI::EventArgs &e);
// Adjust mouse clipping area
virtual void windowResized(Ogre::RenderWindow* rw);
// Unattach OIS before window shutdown (very important under Linux)
virtual void windowClosed(Ogre::RenderWindow* rw);
Ogre::Root* mRoot;
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
Ogre::String mResourcesCfg;
Ogre::String mPluginsCfg;
Ogre::OverlaySystem* mOverlaySystem;
// OgreBites
OgreBites::InputContext mInputContext;
OgreBites::SdkTrayManager* mTrayMgr;
OgreBites::SdkCameraMan* mCameraMan; // Basic camera controller
OgreBites::ParamsPanel* mDetailsPanel; // Sample details panel
OgreBites::TextBox* mWinBox;
OgreBites::TextBox* mLoseBox;
bool mCursorWasVisible; // Was cursor visible before dialog appeared?
bool mShutDown;
//OIS Input devices
OIS::InputManager* mInputManager;
OIS::Mouse* mMouse;
OIS::Keyboard* mKeyboard;
// Added for Mac compatibility
Ogre::String m_ResourcePath;
#ifdef OGRE_STATIC_LIB
Ogre::StaticPluginLoader m_StaticPluginLoader;
#endif
};
//---------------------------------------------------------------------------
#endif // #ifndef __BaseApplication_h_
//---------------------------------------------------------------------------