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
|
{ graphics: lg } = love
import Op from require 'base'
import Registry from require 'registry'
import Copilot from require 'copilot'
class out extends Op
setup: (name, @chld) =>
@@instances[@name] = nil if @name
@name = name\getc!
@@instances[@name] = @
update: =>
@value = @chld\get!
destroy: =>
@@instances[@name] = nil
MARGIN = 16
WIDTH = 24
HEIGHT = 120
@instances: {}
@draw_all: ->
outs = [name for name in pairs @@instances]
table.sort outs
x = MARGIN
lg.setColor 1, 1, 1
for name in *outs
value = @@instances[name].value * HEIGHT
lg.rectangle 'line', x, MARGIN, WIDTH, HEIGHT
lg.rectangle 'fill', x, MARGIN + HEIGHT - value, WIDTH, value
lg.print name, x, MARGIN + HEIGHT + MARGIN
x += WIDTH + MARGIN
env = Registry!
copilot = Copilot arg[#arg], env
love.update = (dt) ->
copilot\poll!
env\update dt
love.draw = ->
out.draw_all!
{
:out
}
|