ressources = { fruits = { quantity = 5, sprite = 33, x = 70 }, money = { quantity = 100, sprite = 35, x = 0 }, jam = { quantity = 0, sprite = 34, x = 100 } } function _init() -- always start on white col = 7 worldtiles = {} init_worldtiles() end function _update() -- press x for a random colour if (btnp(5)) compute_effect_array(worldtiles) end function _draw() cls(0) map(0, 0, 0, 8, 64, 64) camera(0,0) draw_array(worldtiles) draw_ressource_bar() end function draw_ressource_bar() rectfill(0, 0, 127, 7, 1) for _,res in pairs(ressources) do spr(res.sprite, res.x, 0) print(res.quantity, res.x + 8, 1, 6) end end function updatecycle() end function compute_effect_array(array) for obj in all(array) do obj.compute_effet(obj) end end function draw_array(array) for obj in all(array) do obj.draw(obj) end end function new_worldtile(x, y, sprite) local worldtile = {} worldtile.x = x worldtile.y = y worldtile.spr = sprite worldtile.draw = function(this) spr(worldtile.spr,worldtile.x*2*8,8+worldtile.y*2*8, 2, 2) end worldtile.compute_effet = function(this) worldtile.spr = 4 end return worldtile end function init_worldtiles() for x=0,8 do for y=0,8 do sprite = mget(x*2, y*2) flag = fget(sprite, 0) if (flag) then add(worldtiles, new_worldtile(x,y,sprite)) end end end end