-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (46 loc) · 1.5 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
#include "fnHeader.hpp"
using namespace std;
int main (){
//setup
const int width=1280;
const int height=800;
InitAudioDevice(); // loading audio sound fx
SetTargetFPS(60);
InitWindow(width, height,"OG Pong!");
paddle_hit = LoadSound("assets/sfx/paddle_hit.mp3");
bounds_hit = LoadSound("assets/sfx/boundary_hit.mp3");
point_scored = LoadSound("assets/sfx/point_score.mp3");
menuasset=LoadImage("assets/vfx/MENUASSET2.png");
menuscr=LoadTextureFromImage(menuasset);
modeasset=LoadImage("assets/vfx/GAMEMODEASSET1.png");
modescr=LoadTextureFromImage(modeasset);
endasset = LoadImage("assets/vfx/ENDSCREEN_ASSET1.png");
endscr=LoadTextureFromImage(endasset);
//initializing object attributes
initVar(width, height);
//game loop start
while(!WindowShouldClose()){
if(!menuexit)menuScreen();
if(menuexit && !pickMade)modeChoose();
gameoverScreen();
if(gameover) break;
if(!gmode)singleplayer();
else multiplayer();
//game over condition
if(player1Score==5||player2Score==5||CPUScore==5) gameover=true;
EndDrawing();
}
//handling opened resources
UnloadSound(paddle_hit);
UnloadSound(bounds_hit);
UnloadSound(point_scored);
UnloadImage(menuasset);
UnloadTexture(menuscr);
UnloadImage(modeasset);
UnloadTexture(modescr);
UnloadImage(endasset);
UnloadTexture(endscr);
CloseAudioDevice();
CloseWindow();
return 0;
}