-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.lua
More file actions
46 lines (35 loc) · 1.05 KB
/
Copy pathexample.lua
File metadata and controls
46 lines (35 loc) · 1.05 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
--
-- Created by IntelliJ IDEA.
-- User: simon
-- Date: 28/10/2020
-- Time: 23:18
-- To change this template use File | Settings | File Templates.
--
window = engine.GlfwWindow("Simple timer", 800, 600)
application = Application:new()
timer = Component:new({elapsed_time = 0, total_elapsed_time = 0})
camera = engine.CameraComponent()
function timer:update(delta, input)
self.elapsed_time = self.elapsed_time + delta
self.total_elapsed_time = self.total_elapsed_time + delta
end
function timer:render(delta)
if self.elapsed_time >= 3 then
print("Elapsed time is " .. self.total_elapsed_time)
self.elapsed_time = 0
end
end
e = engine.Entity()
function application:initialise(input)
e:add_component("my_timer", timer)
--e:add_component("camera", camera)
self.root:add_child("timer", e)
end
function application:update(delta, input)
if input:is_key_pressed(32) then
t = e:get_component("my_timer")
print("Space bar", t:get("test"))
end
end
engine = Engine:new(application, window, 60)
engine:start()