-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
85 lines (72 loc) · 2.34 KB
/
Game.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
#ifndef __GAME_H__
#define __GAME_H__
#include <Ogre.h>
#include "Ball.h"
#include "Paddle.h"
#include "Physics.h"
#include "Room.h"
#include "btBulletDynamicsCommon.h"
#include "CollisionCallbacks.h"
#include "MyMotionState.h"
#include "NetManager.h"
#include <sstream>
#include <string>
#include "OISKeyboard.h"
#define HOST "baby-ruth"
class Game{
protected:
Paddle* paddle;
Ball* ball;
Room* ballRoom;
public:
Game(){}
virtual void createScene(Ogre::SceneManager* mSceneMgr, Ogre::Camera* mCamera, float& time, int& score, bool& soundOn){}
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt, float& time) = 0;
virtual bool keyPressed(const OIS::KeyEvent& arg) = 0;
virtual bool keyReleased(const OIS::KeyEvent& arg) = 0;
};
class DefaultGame : public Game{
protected:
Physics* physicsEngine;
MyContactResultCallback* targetCallback;
MyCollisionCallback* paddleCallback;
MyCollisionCallback* wallCallback;
public:
DefaultGame();
virtual void createScene(Ogre::SceneManager* mSceneMgr, Ogre::Camera* mCamera, float& time, int& score, bool& soundOn);
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt, float& time);
virtual bool keyPressed(const OIS::KeyEvent& arg);
virtual bool keyReleased(const OIS::KeyEvent& arg);
virtual void contactTests();
};
class ServerGame : public DefaultGame{
NetManager* netMgr;
MyContactResultCallback* p1Callback;
MyContactResultCallback* p2Callback;
Paddle* paddle2; //client paddle
int* score1ptr;
int* score2ptr;
public:
ServerGame() {};
bool initServer(OIS::Keyboard* keyboard);
void createScene(Ogre::SceneManager* mSceneMgr, Ogre::Camera* mCamera, float& time, int& score1, int& score2, bool& soundOn);
virtual void messageClientPlayer();
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt, float& time);
virtual void contactTests();
};
class ClientGame : public Game{
NetManager* netMgr;
int* score1ptr;
int* score2ptr;
Paddle* serverPaddle;
public:
ClientGame() {};
~ClientGame();
bool initClient();
bool connectToHost(std::string);
void createScene(Ogre::SceneManager* mSceneMgr, Ogre::Camera* mCamera, float& time, int& score1, int& score2, bool& soundOn);
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt, float& time);
virtual bool keyPressed(const OIS::KeyEvent& arg);
virtual bool keyReleased(const OIS::KeyEvent& arg);
};
#endif