74 lines
1.1 KiB
Lua
74 lines
1.1 KiB
Lua
|
|
ressources =
|
|
{
|
|
fruits = 0,
|
|
money = 100,
|
|
jam = 0
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
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 |