-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (47 loc) · 1.34 KB
/
main.cpp
File metadata and controls
59 lines (47 loc) · 1.34 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
#include <iostream>
#include <raylib.h>
#include "definitions.hpp"
#include "objects.hpp"
using namespace std;
int main()
{
SetTraceLogLevel(LOG_ERROR);
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE);
SetTargetFPS(FPS);
int w = GetScreenWidth();
int h = GetScreenHeight();
Circle circle(w, h);
Square square(w, h);
float speed = 10.f;
while (!WindowShouldClose())
{
// Event Handling
if (IsKeyDown(KEY_LEFT))
circle.CircleMove({-speed, 0});
if (IsKeyDown(KEY_RIGHT))
circle.CircleMove({+speed, 0});
if (IsKeyDown(KEY_UP))
circle.CircleMove({0, -speed});
if (IsKeyDown(KEY_DOWN))
circle.CircleMove({0, +speed});
// Updates
// Drawing
BeginDrawing();
if (CheckCollisionCircleRec(circle.position, circle.radius, {square.position.x - square.size / 2, square.position.y - square.size / 2, square.size, square.size}))
{
square.isCollision(true);
cout << "Collision: true" << '\n';
}
else
{
square.isCollision(false);
cout << "Collision: false" << '\n';
}
ClearBackground(BG_COLOR);
circle.CircleDraw();
square.SquareDraw();
EndDrawing();
}
CloseWindow();
return 0;
}