-
Notifications
You must be signed in to change notification settings - Fork 0
/
c3dobjects.h
executable file
·231 lines (185 loc) · 5.81 KB
/
c3dobjects.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/****************************************************************************
72 Hour Game Development Contest!
All code (c) Tim Graupmann 2003, 2004.
Feel free to use any of this code with only the following condition:
1) The code is not supported in any way. I am not responsible for any
harm caused to your machine (although I have made every attemp to check
for any possibly damaging stuff)
Enjoy! :)
Credits:
A lot of my code was based on tutorials by GT (www.gametutorials.com).
****************************************************************************/
#ifndef _C3DOBJECT_H
#define _C3DOBJECT_H
#define MAX_CANDYCORNS 20
#define MAX_CANDYGOBBERS 10
#define MAX_BUBBLEGUMS 5
#define MAX_SPEEDBOOSTS 5
#define TYPE_NONE -1
#define TYPE_ORANGE 0
#define TYPE_CANDYCORN 1
#define TYPE_CANDYGOBBER 2
#define TYPE_BUBBLEGUM 3
#define TYPE_SPEEDBOOST 4
class CVector3 {
public:
float X, Y, Z;
CVector3();
~CVector3();
CVector3(const CVector3 & copy);
CVector3(const float x, const float y, const float z);
CVector3 Normalize(const CVector3 vVector);
CVector3 operator + (const CVector3 vVector);
CVector3 operator - (const CVector3 vVector);
CVector3 operator * (const float Scalar);
CVector3 operator / (const float Scalar);
};
float Magnitude(CVector3 vVector);
CVector3 Normalize(CVector3 vVector);
class c3dObject {
public:
// Our base object constructor
c3dObject();
// All in one constructor
c3dObject(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID);
// This changes the position, view, and up vector of the object.
// This is primarily used for initialization
void PositionObject(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ);
// This rotates the object's view around the position depending on the values passed in.
void RotateView(float angle, float X, float Y, float Z);
// This rolls the object's view depending on the speed.
void RollObject(float speed);
// This rolls the object's view around the up view depending on the values passed in.
void RotateUpView(float angle, float x, float y, float z);
// This will move the camera forward or backward depending on the speed
void MoveObject(float speed);
// The object's position
CVector3 m_vPosition;
// The object's view
CVector3 m_vView;
// The object's up vector
CVector3 m_vUpVector;
// The object's strafe vector
CVector3 m_vStrafe;
// The object's type
int m_oType;
// The object's texture ID
int m_TextureID;
};
class c3dCamera : public c3dObject
{
public:
void Look(void);
};
class c3dOrange : public c3dObject
{
public:
short m_State;
float m_Radius;
float m_BubbleRadius;
float m_RotationX;
float m_RollSpeed;
float m_HeightOffset;
long m_TimeToJump;
long m_LastJumpTime;
long m_TimeToSpeed;
long m_LastSpeedTime;
long m_TimeToPenalty;
long m_LastPenaltyTime;
long m_TimeToBubble;
long m_LastBubbleTime;
UINT m_BubbleQty;
UINT m_SpeedBoostQty;
long m_Modified;
int m_LastOpponent;
// All in one constructor
c3dOrange(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID, float RotationX, float RollSpeed,
float HeightOffset, float Radius);
void Update(void);
void Render(void);
};
class c3dBubbleGum : public c3dObject
{
public:
float m_Rotation;
float m_RollSpeed;
float m_HeightOffset;
short m_State;
UINT m_Score;
// All in one constructor
c3dBubbleGum() { }
c3dBubbleGum(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID, float Rotation,
float HeightOffset, short State);
void Update(void);
void Render(void);
};
class c3dSpeedBoost : public c3dObject
{
public:
float m_Rotation;
float m_RollSpeed;
float m_HeightOffset;
short m_State;
UINT m_Score;
// All in one constructor
c3dSpeedBoost() { }
c3dSpeedBoost(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID, float Rotation,
float HeightOffset, short State);
void Update(void);
void Render(void);
};
class c3dCandyCorn : public c3dObject
{
public:
float m_Rotation;
float m_RollSpeed;
float m_HeightOffset;
float m_BubbleRadius;
short m_State;
UINT m_Score;
c3dCandyCorn() { }
// All in one constructor
c3dCandyCorn(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID, float Rotation,
float HeightOffset, short State);
void Update(void);
void Render(void);
};
class c3dCandyGobber : public c3dObject
{
public:
float m_Rotation;
float m_RollSpeed;
float m_HeightOffset;
float m_Radius;
float m_BubbleRadius;
short m_State;
CVector3 m_Color;
UINT m_Score;
c3dCandyGobber() { }
// All in one constructor
c3dCandyGobber(float positionX, float positionY, float positionZ,
float viewX, float viewY, float viewZ,
float upVectorX, float upVectorY, float upVectorZ,
UINT textureID, float Rotation,
float HeightOffset, float Radius, short State);
void Update(void);
void Render(void);
};
#endif