-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathA_include.lua
More file actions
73 lines (62 loc) · 1.16 KB
/
A_include.lua
File metadata and controls
73 lines (62 loc) · 1.16 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--
-- ////\\\\
-- ////\\\\ TUTORIAL
-- ////\\\\ PART 10
-- \\\\////
-- \\\\//// INCLUDE
-- \\\\////
--
-- Main
local view1 = include('lib/view')
local view2 = include('lib/view')
local viewport = { width = 128, height = 64, frame = 0 }
local selection = nil
function init()
redraw()
view1:set_name('view1')
view2:set_name('view2')
view1:move_to(9,8)
view2:move_to(40,21)
select_view(view1)
end
function select_view(view)
print('Select: '..view.name)
if selection then
selection.is_selected = false
end
selection = view
selection.is_selected = true
redraw()
end
-- Interactions
function key(id,state)
if state == 1 then
if id == 2 then
select_view(view1)
elseif id == 3 then
select_view(view2)
end
end
redraw()
end
function enc(id,delta)
if id == 2 then
selection:move_by(delta,0)
elseif id == 3 then
selection:move_by(0,delta)
end
redraw()
end
-- Render
function draw_frame()
screen.level(15)
screen.rect(1, 1, viewport.width-1, viewport.height-1)
screen.stroke()
end
function redraw()
screen.clear()
draw_frame()
view1:draw(screen)
view2:draw(screen)
screen.update()
end