-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformation.cpp
More file actions
99 lines (84 loc) · 2.19 KB
/
Transformation.cpp
File metadata and controls
99 lines (84 loc) · 2.19 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
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
98
99
#include "Transformation.hpp"
#include "../Game/Game.hpp"
#include "../utils.hpp"
#include <cmath>
extern Game game;
void SetPosition(std::string name, int x, int y)
{
Entity& entity = GetEntityByName(name);
entity.x = x;
entity.y = y;
}
int GetX(std::string name)
{
Entity& entity = GetEntityByName(name);
return entity.x;
}
void SetX(std::string name, int x)
{
Entity& entity = GetEntityByName(name);
entity.x = x;
}
int GetY(std::string name)
{
Entity& entity = GetEntityByName(name);
return entity.y;
}
void SetY(std::string name, int y)
{
Entity& entity = GetEntityByName(name);
entity.y = y;
}
int GetWidth(std::string name)
{
Entity& entity = GetEntityByName(name);
return entity.texture.width;
}
void SetWidth(std::string name, int width)
{
Entity& entity = GetEntityByName(name);
entity.texture.width = width;
}
int GetHeight(std::string name)
{
Entity& entity = GetEntityByName(name);
return entity.texture.height;
}
void SetHeight(std::string name, int height)
{
Entity& entity = GetEntityByName(name);
entity.texture.height = height;
}
void Move(std::string name, int x, int y)
{
Entity& entity = GetEntityByName(name);
entity.x += x;
entity.y += y;
}
void Angle(std::string name, float angle)
{
Entity& entity = GetEntityByName(name);
entity.angle = angle;
}
void LookAt(std::string nameA, std::string nameB)
{
Entity& entityA = GetEntityByName(nameA);
Entity& entityB = GetEntityByName(nameB);
entityA.angle = atan2f(entityA.y - entityB.y, entityA.x - entityB.x) * RAD2DEG;
}
void DefineTransformation()
{
game.lua.set_function("SetPosition", SetPosition);
game.lua.set_function("GetX", GetX);
game.lua.set_function("SetX", SetX);
game.lua.set_function("GetY", GetY);
game.lua.set_function("SetY", SetY);
game.lua.set_function("GetWidth", GetWidth);
game.lua.set_function("SetWidth", SetWidth);
game.lua.set_function("GetHeight", GetHeight);
game.lua.set_function("SetHeight", SetHeight);
game.lua.set_function("rec", DrawRectangleLines);
game.lua.set_function("Move", Move);
game.lua.set_function("LookAt", LookAt);
game.lua.set_function("Angle", Angle);
}