-
Notifications
You must be signed in to change notification settings - Fork 1
/
NBS1.c
319 lines (283 loc) · 7.72 KB
/
NBS1.c
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#include<stdio.h>
#include<stdlib.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glut.h>
#include<math.h>
#include<stdbool.h>
#include "draw_bot.h"
#include "on_timer.h"
#include "on_display.h"
#include "draw_anunaki.h"
#include "collision.h"
#include "image.h"
//razmere prozora
int window_width, window_height;
//boolean promenljva koja prati tastere
int keyStates[256];
//promenljive za pomeranje po x i z osi za HB3
int mvX=0, X=0, mvZ=0, Z=0, bot_rotation=0, rot=0, HB3mv=0, rotate = 0;
//promenljive za HB3 sposobnosti
int Teleporting=0, Jump=0, Zoom=0, trail_ID=1, HB3_HP = 10;
float TeleClp = 1;
//The Hammer Is Bangin'
float HammerTime=45, HammerThrow=0, HammerSpin=0, HammerLift=0, HammerMeme=0;
int HammerUp=1, HTGO=0, HTB=0, HITind1 = 1,HITind2 = 1, Tenken = 0;
//promenljive za pomeranje Anunakija i za njegove sposobnosti
int XA=0, ZA=0, mvXA=0, mvZA=0, Amv=0, MIter=0, setMirrors=0, el_rotate=0, mirror_image=0, AnuShoot=0, Anu_HP = 10, AnuShootMV = 0, laserTime = 0;
//deklaracija callback funkcija
static void on_reshape(int width, int height);
static void on_keyboard(unsigned char key, int x, int y);
static void keyUp(unsigned char key, int x, int y);
int main(int argc, char** argv){
//incijalizujemo niz kljuceva koji predstavljaju testaturu
int i;
for(i=0;i<256;i++)
keyStates[i]=0;
//standardna inicijalizacija kazemo da koristimo sistem boja RGB, dva buffera i prepoznaje se dubina
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
//inicijalizacija prozora
glutInitWindowPosition(300,100);
glutInitWindowSize(800,600);
glutCreateWindow("Nerdbot Arena");
//pozivanje callback funkcija
glutDisplayFunc(on_display);
glutKeyboardFunc(on_keyboard);
glutReshapeFunc(on_reshape);
glutTimerFunc(30, on_timer, 0);
glutTimerFunc(50,on_timer_EL,0);
glutKeyboardUpFunc(keyUp);
//postavljenje boje koju zelimo da koristimo za ciscenje
glClearColor(0,0.6,0.6,0);
//palimo test dubine?
glEnable(GL_DEPTH_TEST);
//ukljucujemo normale na objekte zbog osvetljenja
glEnable(GL_NORMALIZE);
/* Ukljucuju se teksture. */
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//malo udebljavamo crtanje linija
glLineWidth(1);
//upadamo u glavnu petlju
glutMainLoop();
//Vracamo nulu :D
return 0;
}
//funkcija se poziva kada podignemo prst sa tastera
void keyUp (unsigned char key, int x, int y) {
keyStates[(int)key] = 0;
}
//desava se klikom na neko dugme na tastaturi
static void on_keyboard(unsigned char key, int x, int y){
collision(1);
//azuriramo globalni niz u kom pratimo koji su tasteri pritisnuti
keyStates[(int)key] = 1;
switch(key)
{
case 27:
exit(0);
break;
//Tenken sposobnost
case 32:
{
if(HammerTime == 45)
{
HammerUp = 0;
Tenken = 1;
}
break;
}
//pomeranje HB3 komentari za A se odnose i na W S D
case 'a':
case 'A':
{
//pre pomeranja se sredjuje rotacija ako bot_rotation nije na 90 azuriraj parametar rot
rotate = 1;
if(bot_rotation == -180)
bot_rotation = 180;
//u zavisnosti od trenutne vrednosti bot_rotation biramo na koju stranu rotiramo da bi uvek isao najkracim putem, dok se rotira ne pomera se
if(bot_rotation < 90 && bot_rotation >= -90){
rot = 5;
HB3mv = 0;
}
else if(bot_rotation < -90 && bot_rotation >-180){
rot = -5;
HB3mv = 0;
}
else if(bot_rotation <= 180 && bot_rotation > 90)
{
rot = -5;
HB3mv = 0;
}
else if(bot_rotation == 90)
{
rot = 0;
}
//parametri kretanja koji se dodaju na X i Z koordinatu HB3
mvX = 0;
mvZ = 1;
collision(1);
break;
}
case 'd':
case 'D':
{
rotate = 1;
if(bot_rotation == 180)
bot_rotation=-180;
if(bot_rotation <= 90 && bot_rotation > -90){
rot = -5;
HB3mv = 0;
}
else if(bot_rotation < -90 && bot_rotation >= -180)
{
rot = 5;
HB3mv = 0;
}
else if(bot_rotation > 90 && bot_rotation < 180)
{
rot = 5;
HB3mv = 0;
}
else if(bot_rotation == -90)
{
rot = 0;
}
mvX = 0;
mvZ = -1;
collision(1);
break;
}
case 'w':
case 'W':
{
rotate = 1;
if(bot_rotation <= 180 && bot_rotation > 0)
{
rot = -5;
HB3mv = 0;
}
else if(bot_rotation >= -180 && bot_rotation < 0)
{
rot = 5;
HB3mv = 0;
}
else if(bot_rotation == 0)
{
rot = 0;
}
mvX = -1;
mvZ = 0;
collision(1);
break;
}
case 's':
case 'S':
{
rotate = 1;
if(bot_rotation >= 0 && bot_rotation < 180){
rot = 5;
HB3mv = 0;
}
else if(bot_rotation < 0 && bot_rotation > -180)
{
rot = -5;
HB3mv = 0;
}
else if(bot_rotation == 180 || bot_rotation == -180){
rot = 0;
}
mvX = 1;
mvZ = 0;
collision(1);
break;
}
//bacanje cekica na f
case 'f':
case 'F':
{
HTGO=1;
//malo odizemo cekic da se ne trtlja po podu
HammerLift=3;
break;
}
//teleportovnje na t
case 't':
case 'T':
{
Teleporting = 1;
break;
}
//kretanje Anunakija
case 'i':
case 'I':
{
//parametri kretanja koji se dodaju na X i Z koordinatu Anunakija
Amv = 1;
collision(2);
mvXA = 1;
mvZA = 0;
break;
}
case 'k':
case 'K':
{
Amv = 1;
collision(2);
mvXA = -1;
mvZA = 0;
break;
}
case 'j':
case 'J':
{
Amv = 1;
collision(2);
mvXA = 0;
mvZA = -1;
break;
}
case 'l':
case 'L':
{
Amv = 1;
collision(2);
mvXA = 0;
mvZA = 1;
break;
}
//Mirror image sposobnost
case 'o':
case 'O':
{
if(mirror_image == 1)
{
break;
}
mirror_image = 1;
setMirrors = 1;
break;
}
//bacanje sfera
case 'p':
case 'P':
{
AnuShoot = 1;
AnuShootMV = 1;
break;
}
//LASER
case 'u':
case 'U':
{
laserTime = 1;
break;
}
}
}
//desava se kad se prozoru promeni razmera
static void on_reshape(int width, int height){
window_width = width;
window_height = height;
}