blob: 6a0eed8bac6f7030eb4af388fefd504c6a6cb71f (
plain)
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
|
-- Global state
win = require("window")
hc = require("party.hc.init")
ecs = require("ecs")
print("hc:", hc)
--Use a collider to decide what to render
x = {
world_e: ecs.Entity(1)
-- local offsets from the world
world_x: 0
world_y: 0
-- Have we selected an input type yet?
controller: {
text_size: 4
}
-- Level information
level: {
graphics:{}
entities:{}
graphic_world: hc.new(5)
}
sync_time: () ->
am.current_time!
}
x.level.collider = x.level.graphic_world\rectangle(0,0,1,1/win.width)
class GraphicsComponent extends ecs.Component
new: (name, properties) =>
print("Got name", name, "and properties", properties)
assert(properties and properties.node , "Failed to find node for graphics component")
super(name, properties)
x.node\append(properties.node)
static: () =>
@@static
node: () =>
@properties.node
x.GraphicsComponent = GraphicsComponent
x
|