-
Notifications
You must be signed in to change notification settings - Fork 4
/
menu.c
531 lines (474 loc) · 23 KB
/
menu.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_gfxPrimitives.h>
#include <SDL_ttf.h>
#include "main.h"
#include "imgload.h"
#include "UI.h"
#include "bg.h"
#include "AI.h"
#include "level.h"
#include "menu.h"
#include "music.h"
#include "text.h"
enum menu_type menu = None;
/** A játék elindulásakor a főmenü kirajzolása */
int Draw_menu(SDL_Surface *screen) {
//Háttér zene
playmusic(mus_main);
// Háttér kép
SDL_Surface *menu = IMG_Load("menu.gif");
SetSize( &menu, kx, ky);
SDL_BlitSurface(menu, NULL, screen, NULL);
SDL_FreeSurface(menu);
// Jobb alsó szöveg
SDL_Color grey = {140, 140, 140};
SDL_Surface *text = RenderText(Cour15, "This game was created by", grey);
int w = text->w;
SDL_Rect textRect = {kx - text->w - 10, ky - 2 * text->h - 20, 0, 0};
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
text = RenderText(Cour15, "Tam\xC3\xA1s Csala", grey);
textRect.x += (w / 2 - text->w/2);
textRect.y = ky - text->h - 10;
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
SDL_Color white = {255, 255, 255};
text = RenderText(Knig35, "Story mode", white);
SDL_Rect storyRect = {kx/2 - text->w/2, 2*ky/5, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &storyRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Survival mode", white);
SDL_Rect survivalRect = {kx/2 - text->w/2, storyRect.y + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &survivalRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Skill practise arena", white);
SDL_Rect practiseRect = {kx/2 - text->w/2, survivalRect.y + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &practiseRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Benchmark", white);
SDL_Rect benchmarkRect = {kx/2 - text->w/2, practiseRect.y + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &benchmarkRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Quit", white);
SDL_Rect quitRect = {kx/2 - text->w/2, benchmarkRect.y + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &quitRect);
SDL_FreeSurface(text);
SDL_Flip(screen);
SDL_Surface *screen_wo_cursor = SDL_CreateRGBSurface(SDL_ANYFORMAT, kx, ky, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
SDL_BlitSurface(screen, NULL, screen_wo_cursor, NULL);
SDL_Event event;
bool mouse_movement = false;
int mouse_x, mouse_y;
SDL_GetMouseState(&mouse_x, &mouse_y);
while(1) {
if(mouse_movement) {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, mouse_x, mouse_y);
SDL_Flip(screen);
mouse_movement = false;
}
while( SDL_PollEvent( &event ) ) {
if(event.type == SDL_KEYDOWN)
if( event.key.keysym.sym == SDLK_ESCAPE) {
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(event.type == SDL_MOUSEBUTTONUP)
if(event.button.button == SDL_BUTTON_LEFT) {
if(storyRect.x < event.motion.x && event.motion.x < storyRect.x + storyRect.w)
if(storyRect.y < event.motion.y && event.motion.y < storyRect.y + storyRect.h) {
if( Select_Difficulty(screen) ) {
level = 1;
current_map = forest;
SDL_FreeSurface(screen_wo_cursor);
return 0;
} else {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, mouse_x, mouse_y);
SDL_Flip(screen);
}
}
if(survivalRect.x < event.motion.x && event.motion.x < survivalRect.x + survivalRect.w)
if(survivalRect.y < event.motion.y && event.motion.y < survivalRect.y + survivalRect.h) {
if( Select_Difficulty(screen) ) {
level = lvl_Survival;
current_map = colisseum;
SDL_FreeSurface(screen_wo_cursor);
return 0;
} else {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, mouse_x, mouse_y);
SDL_Flip(screen);
}
}
if(practiseRect.x < event.motion.x && event.motion.x < practiseRect.x + practiseRect.w)
if(practiseRect.y < event.motion.y && event.motion.y < practiseRect.y + practiseRect.h) {
diff = Easy;
practise = true;
level = lvl_Practise_Arena;
current_map = practise_arena;
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
if(benchmarkRect.x < event.motion.x && event.motion.x < benchmarkRect.x + benchmarkRect.w)
if(benchmarkRect.y < event.motion.y && event.motion.y < benchmarkRect.y + benchmarkRect.h) {
diff = Hard;
benchmark = true;
level = lvl_Benchmark;
current_map = colisseum;
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
if(quitRect.x < event.motion.x && event.motion.x < quitRect.x + quitRect.w)
if(quitRect.y < event.motion.y && event.motion.y < quitRect.y + quitRect.h) {
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
}
}
if(event.type == SDL_MOUSEMOTION) {
mouse_x = event.motion.x;
mouse_y = event.motion.y;
mouse_movement = true;
}
}
return 0;
}
/** Főmenüből megnyíló almenü, amiben a játék nehézségét lehet kiválasztani */
int Select_Difficulty(SDL_Surface *screen) {
// Háttér kép
SDL_Surface *menu = IMG_Load("menu.gif");
SetSize( &menu, kx, ky);
SDL_BlitSurface(menu, NULL, screen, NULL);
SDL_FreeSurface(menu);
// Jobb alsó szöveg
SDL_Color grey = {140, 140, 140};
SDL_Surface *text = RenderText(Cour15, "This game was created by", grey);
int w = text->w;
SDL_Rect textRect = {kx - text->w - 10, ky - 2 * text->h - 20, 0, 0};
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
text = RenderText(Cour15, "Tam\xC3\xA1s Csala", grey);
textRect.x += (w / 2 - text->w/2);
textRect.y = ky - text->h - 10;
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
SDL_Color white = {255, 255, 255};
text = RenderText(Knig35, "Select Difficulty", white);
textRect.x = kx/2 - text->w/2;
textRect.y = 2*ky/5;
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Easy", white);
SDL_Rect easyRect = {kx/2 - text->w/2 - 100*scale, 2*ky/5 + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &easyRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Normal", white);
SDL_Rect normalRect = {kx/2 - text->w/2, 2*ky/5 + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &normalRect);
SDL_FreeSurface(text);
text = RenderText(Knig35, "Hard", white);
SDL_Rect hardRect = {kx/2 - text->w/2 + 100*scale, 2*ky/5 + text->h + 10*scale, text->w, text->h};
SDL_BlitSurface(text, NULL, screen, &hardRect);
SDL_FreeSurface(text);
SDL_Flip(screen);
SDL_Surface *screen_wo_cursor = SDL_CreateRGBSurface(SDL_ANYFORMAT, kx, ky, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
SDL_BlitSurface(screen, NULL, screen_wo_cursor, NULL);
SDL_Event event;
bool mouse_movement = false;
int mouse_x, mouse_y;
SDL_GetMouseState(&mouse_x, &mouse_y);
while(1) {
if(mouse_movement) {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, mouse_x, mouse_y);
SDL_Flip(screen);
mouse_movement = false;
}
while( SDL_PollEvent( &event ) ) {
if(event.type == SDL_KEYDOWN)
if( event.key.keysym.sym == SDLK_ESCAPE) {
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
if(event.type == SDL_MOUSEBUTTONUP)
if(event.button.button == SDL_BUTTON_LEFT) {
if(easyRect.x < event.motion.x && event.motion.x < easyRect.x + easyRect.w)
if(easyRect.y < event.motion.y && event.motion.y < easyRect.y + easyRect.h) {
diff = Easy;
practise = true;
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(normalRect.x < event.motion.x && event.motion.x < normalRect.x + normalRect.w)
if(normalRect.y < event.motion.y && event.motion.y < normalRect.y + normalRect.h) {
diff = Normal;
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(hardRect.x < event.motion.x && event.motion.x < hardRect.x + hardRect.w)
if(hardRect.y < event.motion.y && event.motion.y < hardRect.y + hardRect.h) {
diff = Hard;
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
}
}
if(event.type == SDL_MOUSEMOTION) {
mouse_x = event.motion.x;
mouse_y = event.motion.y;
mouse_movement = true;
}
}
return 0;
}
/** A játék töltése alatt kirajzolt képet létrehozó fv. */
void Loading_screen(SDL_Surface *screen) {
SDL_Surface *menu = IMG_Load("menu.gif");
SetSize( &menu, kx, ky);
SDL_BlitSurface(menu, NULL, screen, NULL);
SDL_FreeSurface(menu);
SDL_Color white = {255, 255, 255};
SDL_Surface *text = RenderText(Knig60, "Loading", white);
SDL_Rect textRect = {kx/2 - text->w/2, ky/2, 0, 0};
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
SDL_Color grey = {140, 140, 140};
text = RenderText(Cour15, "This game was created by", grey);
int w = text->w;
textRect.x = kx - text->w - 10;
textRect.y = ky - 2 * text->h - 20;
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
text = RenderText(Cour15, "Tam\xC3\xA1s Csala", grey);
textRect.x += (w / 2 - text->w/2);
textRect.y = ky - text->h - 10;
SDL_BlitSurface(text, NULL, screen, &textRect);
SDL_FreeSurface(text);
SDL_Flip(screen);
}
/** Játék közbe az Escape megnyomásával (vagy alt+tabbal) behozható menü */
int Quit_menu(SDL_Surface *screen, int *mouse_x, int *mouse_y) {
Uint32 pause_start = GetTicks();
SDL_Surface *menu = SDL_CreateRGBSurface(SDL_ANYFORMAT, kx/8, kx/16, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
// A menünek csak egyes részei lesznek átlátszóak, ezért először rámásolom a menüre a háttér megfelelő részét
SDL_Rect menuRect = {kx/2 - menu->w/2, ky/2 - menu->h/2, menu->w, menu->h};
// A félig átlátszó fekete négyzet
boxRGBA(menu, 0, 0, menu->w, menu->h, 0, 0, 0, 200);
// Szegély
lineRGBA(menu, 0, 0, 0, menu->h - 1, 8, 8, 8, 255);
rectangleRGBA(menu, 1, 0, menu->w - 1, menu->h - 1, 34, 34, 34, 255);
rectangleRGBA(menu, 2, 1, menu->w - 2, menu->h - 2, 15, 15, 15, 255);
SDL_Surface *text;
// A gombok
SDL_Surface *button = IMG_Load("./sprite/etc/button.gif");
SetSize(&button, 5 * menu->w / 6, (5 * menu->w / 6) * button->h / button->w);
SDL_SetAlpha(button, SDL_SRCALPHA|SDL_RLEACCEL , 230);
SDL_Color white = {255, 255, 255};
SDL_Rect resumeButton = {menu->w/2 - button->w/2, menu->h/2 - button->h/2 - menu->h/5, button->w, button->h};
SDL_BlitSurface(button, NULL, menu, &resumeButton);
text = RenderText(Cour15, "Resume", white);
SDL_Rect resumeRect = {menu->w/2 - text-> w/2, menu->h/2 - text->h/2 - menu->h/5, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &resumeRect);
SDL_FreeSurface(text);
SDL_Rect quitButton = {menu->w/2 - button-> w/2, menu->h/2 - button->h/2 + menu->h/5, button->w, button->h};
SDL_BlitSurface(button, NULL, menu, &quitButton);
text = RenderText(Cour15, "Quit", white);
SDL_Rect quitRect = {menu->w/2 - text-> w/2, menu->h/2 - text->h/2 + menu->h/5, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &quitRect);
SDL_FreeSurface(text);
SDL_FreeSurface(button);
// A fejléc a menühöz
SDL_Surface *title = IMG_Load("./sprite/etc/button.gif");
SetSize(&title, menu->w, menu->w * title->h / title->w);
text = RenderText(Cour12, "Little Fighter", white);
SDL_Rect titletextRect = {title->w/2 - text->w/2, title->h/2 - text->h/2, text->w, text->h};
SDL_BlitSurface(text, NULL, title, &titletextRect);
SDL_FreeSurface(text);
SDL_Rect titleRect = {menuRect.x, menuRect.y - title->h, menuRect.w, title->h};
SDL_BlitSurface(title, NULL, screen, &titleRect);
SDL_FreeSurface(title);
SDL_BlitSurface(menu, NULL, screen, &menuRect);
SDL_FreeSurface(menu);
SDL_Surface *screen_wo_cursor = SDL_CreateRGBSurface(SDL_ANYFORMAT, screen->w, screen->h, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
SDL_BlitSurface(screen, NULL, screen_wo_cursor, NULL);
Draw_cursor(screen, *mouse_x, *mouse_y);
SDL_Flip(screen);
SDL_Event event;
bool mouse_movement = false;
while(1) {
if(mouse_movement) {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, *mouse_x, *mouse_y);
SDL_Flip(screen);
mouse_movement = false;
}
while( SDL_PollEvent( &event ) ) {
if(event.type == SDL_KEYDOWN)
if( event.key.keysym.sym == SDLK_ESCAPE) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(event.type == SDL_MOUSEBUTTONUP)
if(event.button.button == SDL_BUTTON_LEFT) {
if(menuRect.x + resumeButton.x < event.motion.x && event.motion.x < menuRect.x + resumeButton.x + resumeButton.w)
if(menuRect.y + resumeButton.y < event.motion.y && event.motion.y < menuRect.y + resumeButton.y + resumeButton.h) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(menuRect.x + quitButton.x < event.motion.x && event.motion.x < menuRect.x + quitButton.x + quitButton.w)
if(menuRect.y + quitButton.y < event.motion.y && event.motion.y < menuRect.y + quitButton.y + quitButton.h) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
}
}
if(event.type == SDL_MOUSEMOTION) {
*mouse_x = event.motion.x;
*mouse_y = event.motion.y;
mouse_movement = true;
}
}
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
/** A játékos halálakor megjelenő menü */
int Death_menu(SDL_Surface *screen, int enemies_killed, int *mouse_x, int *mouse_y) {
Uint32 pause_start = GetTicks();
SDL_Surface *menu = SDL_CreateRGBSurface(SDL_ANYFORMAT, kx/8, kx/8, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
// A menünek csak egyes részei lesznek átlátszóak, ezért először rámásolom a menüre a háttér megfelelő részét
SDL_Rect menuRect = {kx/2 - menu->w/2, ky/2 - menu->h/2, menu->w, menu->h};
// A félig átlátszó fekete négyzet
boxRGBA(menu, 0, 0, menu->w, menu->h, 0, 0, 0, 200);
// Szegély
lineRGBA(menu, 0, 0, 0, menu->h - 1, 8, 8, 8, 255);
rectangleRGBA(menu, 1, 0, menu->w - 1, menu->h - 1, 34, 34, 34, 255);
rectangleRGBA(menu, 2, 1, menu->w - 2, menu->h - 2, 15, 15, 15, 255);
SDL_Surface *text;
SDL_Color white = {255, 255, 255};
if(level == lvl_Survival || level == lvl_Benchmark) {
text = RenderText(Cour10, benchmark ? "Benchmark points:" : "Enemies Killed:", white);
SDL_Rect Rect = {menu->w/2 - text-> w/2, menu->h/8, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &Rect);
SDL_FreeSurface(text);
char c[50];
sprintf(c, "%d", enemies_killed);
text = RenderText(Cour20, c, white);
SDL_Rect Rect2 = {menu->w/2 - text-> w/2, menu->h/6 + text->h / 2, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &Rect2);
SDL_FreeSurface(text);
} else {
text = RenderText(Cour25, "Defeat!", white);
SDL_Rect Rect = {menu->w/2 - text-> w/2, menu->h/8, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &Rect);
SDL_FreeSurface(text);
}
// A gombok
SDL_Surface *button = IMG_Load("./sprite/etc/button.gif");
SetSize(&button, 5 * menu->w / 6, (5 * menu->w / 6) * button->h / button->w);
SDL_SetAlpha(button, SDL_SRCALPHA|SDL_RLEACCEL , 230);
SDL_Rect resumeButton = {menu->w/2 - button-> w/2, menu->h/2 - button->h/2, button->w, button->h};
SDL_BlitSurface(button, NULL, menu, &resumeButton);
text = RenderText(Cour20, "Retry", white);
SDL_Rect resumeRect = {menu->w/2 - text-> w/2, menu->h/2 - text->h/2, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &resumeRect);
SDL_FreeSurface(text);
SDL_Rect quitButton = {menu->w/2 - button-> w/2, menu->h/2 - button->h/2 + menu->h/4, button->w, button->h};
SDL_BlitSurface(button, NULL, menu, &quitButton);
text = RenderText(Cour20, "Quit", white);
SDL_Rect quitRect = {menu->w/2 - text-> w/2, menu->h/2 - text->h/2 + menu->h/4, text->w, text->h};
SDL_BlitSurface(text, NULL, menu, &quitRect);
SDL_FreeSurface(text);
SDL_FreeSurface(button);
// A fejléc a menühöz
SDL_Surface *title = IMG_Load("./sprite/etc/button.gif");
SetSize(&title, menu->w, menu->w * title->h / title->w);
text = RenderText(Cour12, "Little Fighter", white);
SDL_Rect titletextRect = {title->w/2 - text->w/2, title->h/2 - text->h/2, text->w, text->h};
SDL_BlitSurface(text, NULL, title, &titletextRect);
SDL_FreeSurface(text);
SDL_Rect titleRect = {menuRect.x, menuRect.y - title->h, menuRect.w, title->h};
SDL_BlitSurface(title, NULL, screen, &titleRect);
SDL_FreeSurface(title);
SDL_BlitSurface(menu, NULL, screen, &menuRect);
SDL_FreeSurface(menu);
SDL_Surface *screen_wo_cursor = SDL_CreateRGBSurface(SDL_ANYFORMAT, screen->w, screen->h, screen_bpp, screen_rmask, screen_gmask, screen_bmask, screen_amask);
SDL_BlitSurface(screen, NULL, screen_wo_cursor, NULL);
Draw_cursor(screen, *mouse_x, *mouse_y);
SDL_Flip(screen);
SDL_Event event;
bool mouse_movement = false;
while(1) {
if(mouse_movement) {
SDL_BlitSurface(screen_wo_cursor, NULL, screen, NULL);
Draw_cursor(screen, *mouse_x, *mouse_y);
SDL_Flip(screen);
mouse_movement = false;
}
while( SDL_PollEvent( &event ) ) {
if(event.type == SDL_KEYDOWN)
if( event.key.keysym.sym == SDLK_ESCAPE) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
if(event.type == SDL_MOUSEBUTTONUP)
// Fontos hogy ez ne mousebuttondown legyen, mert akkor a kilépésnél a főmenübe
// is érzékelné még kattintást azaz a kilépés után egyből be is lépne a practise arenába
if(event.button.button == SDL_BUTTON_LEFT) {
if(menuRect.x + resumeButton.x < event.motion.x && event.motion.x < menuRect.x + resumeButton.x + resumeButton.w)
if(menuRect.y + resumeButton.y < event.motion.y && event.motion.y < menuRect.y + resumeButton.y + resumeButton.h) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 1;
}
if(menuRect.x + quitButton.x < event.motion.x && event.motion.x < menuRect.x + quitButton.x + quitButton.w)
if(menuRect.y + quitButton.y < event.motion.y && event.motion.y < menuRect.y + quitButton.y + quitButton.h) {
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
}
if(event.type == SDL_MOUSEMOTION) {
*mouse_x = event.motion.x;
*mouse_y = event.motion.y;
mouse_movement = true;
}
}
}
paused += GetTicks() - pause_start;
aNextTick = dNextTick = GetTicks();
SDL_FreeSurface(screen_wo_cursor);
return 0;
}
#include "music.h"
void Credits_menu(SDL_Surface *screen) {
playmusic(mus_num);
boxRGBA(screen, 0, 0, kx, ky, 0, 0, 0, 255);
SDL_Color white = {255, 255, 255};
SDL_Surface *text = RenderText(Knig60, "LittleFighter", white);
SDL_Rect titlerect = {kx/2 - text->w/2, 20*scale, 0, 0};
SDL_BlitSurface(text, NULL, screen, &titlerect);
SDL_FreeSurface(text);
text = RenderText(Cour25, "This game was created by Tam\xC3\xA1s Csala.", white);
SDL_Rect creditsrect = {kx/2 - text->w/2, ky/2 - text->h/2 - 20*scale, 0, 0};
SDL_BlitSurface(text, NULL, screen, &creditsrect);
SDL_FreeSurface(text);
text = RenderText(Cour25, "Thanks for playing! :)", white);
SDL_Rect thanksrect = {kx/2 - text->w/2, ky/2 - text->h/2 + 60*scale, 0, 0};
SDL_BlitSurface(text, NULL, screen, &thanksrect);
SDL_FreeSurface(text);
SDL_Flip(screen);
}