-
Notifications
You must be signed in to change notification settings - Fork 0
/
Archimedes.lua
45 lines (39 loc) · 1.33 KB
/
Archimedes.lua
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
archimedes = {}
Archimedes = archimedes
---@class THlib.archimedes.expand
archimedes.expand = {}
function archimedes.expand:init(center, radius, angle, omiga, deltar)
self.center = center
self.radius = radius
self.angle = angle
self._omiga = omiga
self.deltar = deltar
self.x = self.center.x + self.radius * cos(self.angle)
self.y = self.center.y + self.radius * sin(self.angle)
end
function archimedes.expand:frame()
self.radius = self.radius + self.deltar
self.angle = self.angle + self._omiga
self.x = self.center.x + self.radius * cos(self.angle)
self.y = self.center.y + self.radius * sin(self.angle)
end
---@class THlib.archimedes.rotation
archimedes.rotation = {}
function archimedes.rotation:init(center, radius, angle, omiga, time)
self.center = center
self.radius = 0
self.angle = angle
self._omiga = omiga
self.time = time or 60
self.deltar = radius / self.time
self.x = self.center.x + self.radius * cos(self.angle)
self.y = self.center.y + self.radius * sin(self.angle)
end
function archimedes.rotation:frame()
if self.timer <= self.time then
self.radius = self.radius + self.deltar
end
self.angle = self.angle + self._omiga
self.x = self.center.x + self.radius * cos(self.angle)
self.y = self.center.y + self.radius * sin(self.angle)
end