-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
60 lines (52 loc) · 1.47 KB
/
main.c
File metadata and controls
60 lines (52 loc) · 1.47 KB
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
#include "consts.h"
#include "raylib.h"
#include "systems.h"
#include "world.h"
int main(void) {
//--SETUP--
InitWindow(SCREEN_WIDHT, SCREEN_HEIGHT, "Pong ECS");
InitAudioDevice();
SetTargetFPS(60);
World worldGame = {
0,
.wall_collide_sfx = LoadSound("assets/colPaddle.wav"),
.paddle_collide_sfx = LoadSound("assets/colParede.wav"),
.score_sfx = LoadSound("assets/soundPoint.wav"),
};
//--CRIAÇÃO DE ENTIDADES
// Paddle 1 <--
CreatePaddle(&worldGame, 20, KEY_W, KEY_S, 0, GAMEPAD_BUTTON_LEFT_FACE_UP,
GAMEPAD_BUTTON_LEFT_FACE_DOWN);
// Paddle 2 -->
CreatePaddle(&worldGame, GetScreenWidth() - (PADLE_WIDTH + 20), KEY_UP,
KEY_DOWN, 1, GAMEPAD_BUTTON_LEFT_FACE_UP,
GAMEPAD_BUTTON_LEFT_FACE_DOWN);
// TopWall
CreateWall(&worldGame, 0);
// BottonWall
CreateWall(&worldGame, GetScreenHeight() - WALL_WIDTH);
// Ball
CreateBall(&worldGame);
SBallInit(&worldGame);
while (!WindowShouldClose()) {
//--UPDATE--
SMoviment(&worldGame);
SScore(&worldGame);
SInput(&worldGame);
SCollisionRects(&worldGame);
SCollisionBallRect(&worldGame);
//--DRAW--
BeginDrawing();
ClearBackground(DARKBLUE);
SRender(&worldGame);
EndDrawing();
//--DEBUG--
// DebugSystem(&worldGame);
}
UnloadSound(worldGame.wall_collide_sfx);
UnloadSound(worldGame.paddle_collide_sfx);
UnloadSound(worldGame.score_sfx);
CloseAudioDevice();
CloseWindow();
return 0;
}