-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
100 lines (71 loc) · 2.65 KB
/
main.cpp
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
#include "Menu.h"
#include "Levels.h"
#include "Utilities.h"
int main () {
srand(time(0));
Utilities utilities;
const int screenWidth = 1920;
const int screenHeight = 1080;
InitWindow(screenWidth, screenHeight, "Angry Sharks");
InitAudioDevice();
//Çalışmıyor.
Image icon = LoadImage("../resources/icon.psd");
SetWindowIcon(icon);
SetWindowState(FLAG_WINDOW_UNDECORATED);
SetWindowState(FLAG_VSYNC_HINT);
int monitor = GetCurrentMonitor();
if(GetMonitorWidth(monitor) == screenWidth && GetMonitorHeight(monitor) == screenHeight) {
SetWindowState(FLAG_FULLSCREEN_MODE);
ToggleFullscreen();
}
SetTargetFPS(60);
int gameScreenWidth = 1920;
int gameScreenHeight = 1080;
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
SetTextureFilter(target.texture, TEXTURE_FILTER_BILINEAR);
Menu menu;
Levels level_1(1,Player(1), menu);
Levels level_2(2,Player(2), menu);
Levels level_3(3,Player(3), menu);
PlayMusicStream(menu.ocean);
PlayMusicStream(menu.menuMusic);
while (!menu.exitGame) {
UpdateMusicStream(menu.menuMusic);
UpdateMusicStream(menu.ocean);
SetMusicVolume(menu.menuMusic, menu.music_volume);
SetMusicVolume(menu.ocean, 0);
while (menu.init) {
menu.raylib_animation();
}
BeginTextureMode(target);
if(!menu.startGame) {
if (!menu.info) {
menu.draw();
} else {
menu.drawInfo();
}
menu.checkButton();
}
if (menu.startGame && menu.firstLevelStart) {
level_1.levelInit();
} else if (menu.startGame && menu.firstLevelComplete) {
level_2.levelInit();
} else if (menu.startGame && menu.secondLevelComplete) {
level_3.levelInit();
}
EndTextureMode();
BeginDrawing();
ClearBackground(BLACK);
float newScreenHeight = utilities.GetResizedScreenHeight((float)gameScreenWidth, (float)gameScreenHeight, (float)GetScreenWidth());
Rectangle targetRec = {0, 0, static_cast<float>(target.texture.width), static_cast<float>(-target.texture.height)};
Rectangle targetDes = {0, ((float)GetScreenHeight() - newScreenHeight)/2, (float)GetScreenWidth(), newScreenHeight};
Vector2 origin = {0, 0};
DrawTexturePro(target.texture, targetRec,targetDes, origin, 0, RAYWHITE);
EndDrawing();
}
UnloadRenderTexture(target);
UnloadMusicStream(menu.ocean);
UnloadMusicStream(menu.menuMusic);
CloseAudioDevice();
CloseWindow();
}