pico-8 cartridge // http://www.pico-8.com version 41 __lua__ -- function _init() --start_scene("title") start_scene("level") end function _update() if _scene and _scene.update then _scene.update() end end function _draw() if _scene and _scene.draw then _scene.draw() end end function start_scene(name) _scene = _scenes[name] _scene_start = time() if _scene.start then _scene.start() end end function scene_time() return time() - _scene_start end _scene = nil _scenes = {} _scene_start = 0 function draw_title() cls() print("title " .. scene_time()) end function update_title() if scene_time() > 2 then start_scene("menu") end end function draw_menu() cls() print("menu " .. scene_time()) end function update_menu() end function start_level() walls = {} walls[30]={{0,10}, {25,30}, {38,44}} walls[40]={{5,15}, {20,25}, {40,50}} walls[50]={{5,10}, {20,30}, {45,55}} walls[60]={{5,15}, {20,25}, {40,50}} walls[70]={{0,10}, {20,30}, {44,55}} walls[80]={{5,15}, {20,25}, {40,50}} walls[90]={{0,10}, {25,30}, {38,44}} the_line = 64 spr_frame = 1 end function draw_side(right) for y, platforms in pairs(walls) do for plat in all(platforms) do if right then line(128-plat[1], y, 128-plat[2], y, DARK) else line(plat[1], y, plat[2], y, LIGHT) end end end end function draw_level() --palt(0, false) cls(0) draw_side(false) spr(spr_frame, the_line-8, 120, 1, 1, false) rectfill(the_line, 0, 128, 128, LIGHT) draw_side(true) pal({[LIGHT]=DARK}) spr(spr_frame, the_line, 120, 1, 1, true) pal() end function update_level() spr_frame += .1 if spr_frame >= 4 then spr_frame = 1 end if btn(0) then the_line -= 1 end if btn(1) then the_line += 1 end end LIGHT = 6 DARK = 0 _scenes.title = {start=nil, draw=draw_title, update=update_title} _scenes.menu = {start=nil, draw=draw_menu, update=nil} _scenes.level = {start=start_level, draw=draw_level, update=update_level} __gfx__ 00000000000060000000600000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00700700000060060000600600006006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000000666660006666600066666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00700700000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000606000006060000060600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000600600006060000600600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000