-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
97 lines (72 loc) · 2.4 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
// * Developed by
// * Yago Miguel Nunes (Notherman)
// :3 Clarisse Rosseti (RezeScarlet)
/*
- Criar um menu com opções de pontuação para partidas
- Power ups
- Aumentar retangulo
- Mudar a cor do fundo do jogo (epilepsicia)
- Mudar tamanho da bola
- Os pontos ganham hitbox e perdem pontos se acertados
- Barrinha de duração
// - Testar o wrapper de c++
// - Player class and methods
- Menu de configurações
- adaptar jogo para resoluções maiores
- Configuração de resolução e janela
- FPS adaptativo
- configurar delta time
- sistema de angulo para colisão
*/
#include "PowerUp.hpp"
#include "Timer.hpp"
using namespace std;
int main() {
// Anti aliasing
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(854, 480, "RayPong");
SetTargetFPS(60);
Screen screen;
Timer timer;
Player player1(1);
Player player2(2);
Ball ball(player1);
PowerUp powerUp;
while (WindowShouldClose() == false) {
timer.RunTimer(GetFPS());
if (timer.getFrame() == 60) {
ball.Accelerate(0.1);
}
ball.Collide(player1, player2);
ball.Move();
// Player collision and Input
player1.Move(KeyboardKey(KEY_W), KeyboardKey(KEY_S));
player2.Move(KeyboardKey(KEY_UP), KeyboardKey(KEY_DOWN));
// Shape drawing
BeginDrawing();
if (powerUp.visible) {
powerUp.Collide(ball);
DrawTriangle(powerUp.v1, powerUp.v2, powerUp.v3, WHITE);
} else if (timer.getSec() % 5 == 0){
powerUp.Respawn();
}
ClearBackground(BLACK);
DrawRectangleRec(player1.rect, WHITE);
DrawRectangleRec(player2.rect, WHITE);
DrawText(TextFormat("%d", player1.score), screen.w / 4, 40, 40, WHITE);
DrawText(TextFormat("%d", player2.score), screen.w * 3 / 4, 40, 40, WHITE);
DrawLine(screen.w / 2, 0, screen.w / 2, screen.h, WHITE);
DrawCircle(ball.GetX(), ball.GetY(), ball.radius, WHITE);
// Debug stuff
DrawCircleV(player1.center, 3, RED);
DrawCircleV(player2.center, 3, RED);
DrawCircleV(powerUp.position, 3, RED);
DrawCircleV(powerUp.v1, 3, GREEN);
DrawCircleV(powerUp.v2, 3, BLUE);
DrawCircleV(powerUp.v3, 3, PURPLE);
DrawLine(0, screen.h / 2, screen.w, screen.h / 2, RED);
EndDrawing();
}
CloseWindow();
return 0;
}