-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (54 loc) · 1.6 KB
/
main.cpp
File metadata and controls
66 lines (54 loc) · 1.6 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
61
62
63
64
65
66
#include <iostream>
#include <raylib.h>
#include <raymath.h>
#include "definitions.hpp"
#include "triangle.hpp"
using namespace std;
int main()
{
SetTraceLogLevel(LOG_ERROR);
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE);
SetTargetFPS(FPS);
float w = (float)GetScreenWidth();
float h = (float)GetScreenHeight();
// Main loop
Triangle triangle((int)(w / 2.f),
(int)(h / 2.f),
100,
BLUE,
true);
float speed = 10.f;
while (!WindowShouldClose())
{
// Event Handling
if (IsKeyDown(KEY_A))
triangle.MoveTriangle(-speed, 0);
if (IsKeyDown(KEY_D))
triangle.MoveTriangle(+speed, 0);
if (IsKeyDown(KEY_W))
triangle.MoveTriangle(0, -speed);
if (IsKeyDown(KEY_S))
triangle.MoveTriangle(0, +speed);
if (IsKeyDown(KEY_E))
triangle.RotateTriangle(.1f);
if (IsKeyDown(KEY_Q))
triangle.RotateTriangle(-.1f);
if (IsKeyDown(KEY_SPACE))
{
triangle.ResetTrianglePosition();
triangle.ResetTriangleRotation();
}
// Updates
Vector2 mousePos = GetMousePosition();
triangle.RotateToVector(mousePos);
// cout << "MOUSE: \t" << "x: " << mousePos.x << "\ty: " << mousePos.y << '\n';
// Drawing
BeginDrawing();
ClearBackground(BG_COLOR);
triangle.Draw();
DrawCircle((int)mousePos.x, (int)mousePos.y, 10, RED);
EndDrawing();
}
CloseWindow();
return 0;
}