Compare commits
4 Commits
1970641149
...
18776cbb68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18776cbb68 | ||
|
|
20c8782800 | ||
|
|
b62fbdf465 | ||
|
|
5e9fc64c0a |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/.vscode/.gitignore
|
||||
88
choco.lua
88
choco.lua
@@ -1,17 +1,97 @@
|
||||
|
||||
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)) 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)
|
||||
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
|
||||
Reference in New Issue
Block a user