pico-8 cartridge // http://www.pico-8.com version 43 __lua__ -- game main loop game_state={ state = 1 -- 1: title 2: game 3: over } function _init() make_player(60,60,1) end function _update() -- update game_objects for object in all(game_objects) do object:update() end end function _draw() cls() -- draw game_objects for object in all(game_objects) do object:draw() end end -->8 -- game objects game_objects={} object_type={ player=1, plattform=2, ruby=3 } -- player class: function make_player(_x,_y,_sprite) local object={ x=_x, y=_y, sprite=_sprite, obj_type=object_type.player } function object:update() if btn(⬆️) then self.y -=1 end if btn(⬇️) then self.y +=1 end if btn(⬅️) then self.x -=1 end if btn(➡️) then self.x +=1 end if self.y>120 then self.y=120 end if self.y<0 then self.y=0 end if self.x>120 then self.x=120 end if self.x<0 then self.x=0 end end function object:draw() spr(self.sprite,self.x,self.y) end add(game_objects, object) return object end --[[ template: function make_object(_x,_y) local object={ x=_x, y=_y } function object:update() end function object:draw() spr(1,x,y) end add(game_objects, object) return object end --]] __gfx__ 000000000077aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000077aaaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0070070077a0a0aa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000770007aaaaaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000aaa0aa0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00700700aaa9009a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000aa999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000aa99000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000