diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..811faee --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.vscode/.gitignore diff --git a/choco.lua b/choco.lua index 1a4bf4d..e5a7673 100644 --- a/choco.lua +++ b/choco.lua @@ -1,17 +1,74 @@ +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)) col = 8 + rnd(8) + if (btnp(5)) compute_effect_array(worldtiles) end function _draw() - cls(1) - circfill(64,64,32,col) - spr(1,64,64, 2,2) + 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 \ No newline at end of file