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
|
ecs = require("ecs")
world = require("world")
sprites = require("world.sprites")
class TestGraphicComponent extends world.GraphicsComponent
@test_size = 0.5
@static = false
buf_size: () =>
6
populate_buf: (geom_view, normal_view, offset) =>
assert(@properties.pos, "Test entity needs a position")
@buf = geom_view
h = @@test_size / 2
pos = @properties.pos
geom_view[1] = vec3(-h,-h,1) + pos
geom_view[2] = vec3(-h,h,1) + pos
geom_view[3] = vec3(-h,-h,1) + pos
geom_view[4] = vec3(h,h,1) + pos
geom_view[5] = vec3(h,-h,1) + pos
geom_view[6] = vec3(-h,-h,1) + pos
uv = sprites.player_normal
normal_view[1] = vec2(uv.s1,uv.t1)
normal_view[2] = vec2(uv.s1,uv.t2)
normal_view[3] = vec2(uv.s2,uv.t2)
normal_view[4] = vec2(uv.s2,uv.t2)
normal_view[5] = vec2(uv.s2,uv.t1)
normal_view[6] = vec2(uv.s1,uv.t1)
class TestEntity extends ecs.Entity
new: (id, pos) =>
super(id,{
graphic: TestGraphicComponent("graphic",{pos: pos})
})
{:TestEntity}
|