-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyOpenGLView.h
More file actions
221 lines (184 loc) · 4.73 KB
/
MyOpenGLView.h
File metadata and controls
221 lines (184 loc) · 4.73 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#if !defined(AFX_MYOPENGLVIEW_H__0BFF0473_8B7E_11D5_8639_00E01890ACE0__INCLUDED_)
#define AFX_MYOPENGLVIEW_H__0BFF0473_8B7E_11D5_8639_00E01890ACE0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyOpenGLView.h : header file
//
#include "OpenGLView.h"
#include "floor.h"
#include "pyramid.h"
#include "friend.h"
#include "good.h"
#include "MachineGun.h"
#include "foe.h"
#include "house.h"
#include "silo.h"
#include "pine.h"
#include "smallpine.h"
#include "Explosion.h"
#include "shell.h"
#include "bullet.h"
#include "MySocket.h"
#include "JoinDialog.h"
#include <GL/gl.h>
#include <GL/glu.h>
//#include <GL/glut.h>
#include <vector>
using namespace std;
#define NUMBER_OF_ENEMIES 20
#define NUMBER_OF_HOUSES 58
#define NUMBER_OF_PYRAMIDS 20
#define NUMBER_OF_FRIENDLIES 5
#define NUMBER_OF_PINES 44
#define NUMBER_OF_SMALL_PINES 75
#define NUMBER_OF_SILOS 5
/////////////////////////////////////////////////////////////////////////////
// CMyOpenGLView view
struct Packet {
// packet type:
// 0 Friend (opponent)
// 1 Shell
// 2 Bullet
// 3 Damage to our tank
// 4 Damage to friendly tanks
// 5 Damage to enemy tanks
// 6 Damage to houses
// 7 Damage to pine trees
// 8 Damage to small pine trees
// 9 Damage to silos
// 10 Spawn site notification
// 11 Damage to opponent
int packetType;
int id;
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat azimuth;
GLfloat elevation;
GLfloat rotation;
GLfloat rotationX;
GLfloat rotationY;
GLfloat speed;
GLfloat damage;
// bool isDestroyed;
bool mgLatch;
bool spawnSiteActive;
};
class CMyOpenGLView : public COpenGLView
{
protected:
CMyOpenGLView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMyOpenGLView)
// Attributes
public:
// Operations
public:
virtual void OnDraw(CDC* pDC);
void setUpLighting();
double ElapsedTimeInMSSinceLastShot() {
return timeGetTime() - previousShotTime;
} //
bool setUpTextures();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyOpenGLView)
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CMyOpenGLView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CMyOpenGLView)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnCollisionOn();
afx_msg void OnCollisionOff();
afx_msg void OnHost();
afx_msg void OnJoin();
afx_msg void OnDisconnect();
afx_msg void OnSingle();
afx_msg void OnMulti();
afx_msg void OnQuit();
afx_msg LRESULT OnMCINotify(WPARAM wParam, LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Draw scene objects
void drawScene();
DWORD PlayMusic(LPSTR); // Plays MIDI files
// Set the view point
void setViewPoint();
void updateScene();
BOOL OpenGLInit();
GLfloat translationVector[3];
Friend ourTank;
MachineGun mg;
vector<Pyramid*> pyramid;
vector<Good*> friendly;
vector<Foe*> enemy;
vector<House*> house;
vector<Silo*> silo;
vector<Pine*> pine;
vector<SmallPine*> smallPine;
vector<Shell*> shells;
vector<Bullet*> bullets;
Friend opponent;
MachineGun oppMG;
vector<Shell*> oppShells;
vector<Bullet*> oppBullets;
//texture
GLuint brickImage;
GLuint siding1Image;
GLuint marbleImage;
GLuint skyImage;
GLuint tilesImage;
GLuint shingleImage;
GLuint camoImage;
GLuint dcamoImage;
GLfloat xDist, yDist, zDist, dist, minDist;
GLfloat azimuth, elevation, rotation;
float calculateRelativeBearing(GLfloat, GLfloat);
void respawn();
double previousShotTime;
double elapsedShotTime;
double gameStartTime;
bool shotFired;
bool mgLatch;
bool collisionDetection;
bool bulletCollision;
bool shellCollision;
bool startGame;
bool gameOver;
bool playedFinalSound;
GLfloat spawnSites[4][3];
bool spawnSiteActive[4];
int spawnSite;
int score;
CString m_ip;
int m_iPort;
CMySocket m_connectSocket;
CMySocket m_listenSocket;
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
UINT wDeviceID;
char* backgroundMusic;
CJoinDialog joinDialog;
bool multiPlayer;
bool server;
void CheckError(int);
public:
void OnConnect();
void OnClose();
void OnSend();
void OnReceive();
void OnAccept();
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYOPENGLVIEW_H__0BFF0473_8B7E_11D5_8639_00E01890ACE0__INCLUDED_)