GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — tutorial/5_output.lua at master · neauoire/tutorial Expand file tree/ Copy path5_output.luaMore file actions 117 lines (97 loc) · 2.08 KB / Copy path5_output.luaFile metadata and controls117 lines (97 loc) · 2.08 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 -- -- ////\\\\ -- ////\\\\ TUTORIAL -- ////\\\\ PART 5 -- \\\\//// -- \\\\//// OUTPUT -- \\\\//// -- engine.name = 'OutputTutorial' local viewport = { width = 128, height = 64, frame = 0 } local focus = { x = 0, y = 0 } -- Main function init() -- Render Style screen.level(15) screen.aa(0) screen.line_width(1) -- Center focus reset() -- Render redraw() end function reset() focus.x = viewport.width/2 focus.y = viewport.height/2 end -- Interactions function key(id,state) reset() redraw() end function enc(id,delta) if id == 2 then focus.x = clamp(focus.x + delta,6,123) elseif id == 3 then focus.y = clamp(focus.y + delta,6,59) re.time = clamp(focus.y/viewport.height,0.05,4) end redraw() end -- Render function draw_frame() screen.rect(1, 1, viewport.width-1, viewport.height-1) screen.stroke() end function draw_crosshair() screen.move(focus.x,focus.y - 4) screen.line(focus.x,focus.y - 2) screen.move(focus.x - 4,focus.y) screen.line(focus.x - 2,focus.y) screen.move(focus.x,focus.y + 3) screen.line(focus.x,focus.y + 1) screen.move(focus.x + 3,focus.y) screen.line(focus.x + 1,focus.y) screen.stroke() for i = viewport.width,1,-1 do if i % 2 == 1 then screen.move(i, focus.y) screen.line(i + 1, focus.y) end end for i = viewport.height,1,-1 do if i % 2 == 1 then screen.move(focus.x, i) screen.line(focus.x, i + 1) end end end function draw_freq() screen.move(5,viewport.height - (8 * 1)) screen.text(get_freq()..'hz') screen.move(5,viewport.height - (8 * 2)) screen.text(clamp(focus.y/viewport.height,0.05,4)..'ms') end function redraw() screen.clear() draw_frame() draw_crosshair() draw_freq() screen.stroke() screen.update() end -- Utils function clamp(val,min,max) return val < min and min or val > max and max or val end function get_freq() return ((focus.x/viewport.width) * 700) + 300 end -- Interval re = metro.init() re.time = 0.5 re.event = function() viewport.frame = viewport.frame + 1 engine.hz(get_freq()) end re:start() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |