split to files

This commit is contained in:
bozarre
2025-12-28 18:46:34 +01:00
parent 18776cbb68
commit 34d70d8be9
4 changed files with 106 additions and 85 deletions

View File

@@ -1,38 +1,11 @@
ressources =
{
fruits =
{
quantity = 5,
sprite = 33,
x = 70
},
money =
{
quantity = 100,
sprite = 35,
x = 0
},
jam =
{
quantity = 0,
sprite = 34,
x = 100
}
}
function _init() function _init()
-- always start on white playercontroler_init()
col = 7
worldtiles = {} worldtiles = {}
init_worldtiles()
end end
function _update() function _update()
-- press x for a random colour
if (btnp(5)) compute_effect_array(worldtiles) if (btnp(5)) compute_effect_array(worldtiles)
playercontroler_update()
end end
function _draw() function _draw()
@@ -41,57 +14,5 @@ function _draw()
camera(0,0) camera(0,0)
draw_array(worldtiles) draw_array(worldtiles)
draw_ressource_bar() draw_ressource_bar()
end playercontroler_draw()
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 end

View File

@@ -1,6 +1,9 @@
pico-8 cartridge // http://www.pico-8.com pico-8 cartridge // http://www.pico-8.com
version 43 version 43
__lua__ __lua__
#include world.lua
#include playercontroler.lua
#include choco.lua #include choco.lua
__gfx__ __gfx__
@@ -28,12 +31,15 @@ __gfx__
000000000888883001888810499aaaa4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000888883001888810499aaaa4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000888e8000188e81004999940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000888e8000188e81004999940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000111111000444400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000111111000444400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__ __map__
0909090909090909090903040909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0909090909090909090903040909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
091909090909090a0909131409090a0900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 091909090909090a0909131409090a0900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09090a0909090909090909090909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 09090a0909090102090909090909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09090909090901020909090909090c1c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 09090909090911120909090909090c1c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09070809090911120909190909091a0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 09070809090909090909190909091a0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0917180909090909090909090a090f0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0917180909090909090909090a090f0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0909090909090909090909090909090e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0909090909090909090909090909090e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
090909090a090506090909190909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 090909090a090506090909190909090900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

11
playercontroler.lua Normal file
View File

@@ -0,0 +1,11 @@
function playercontroler_init()
end
function playercontroler_update()
end
function playercontroler_draw()
end

83
world.lua Normal file
View File

@@ -0,0 +1,83 @@
ressources =
{
fruits =
{
quantity = 5,
sprite = 33,
x = 70
},
money =
{
quantity = 100,
sprite = 35,
x = 0
},
jam =
{
quantity = 0,
sprite = 34,
x = 100
}
}
buildings = {
jam_workshop =
{
sprite = 1,
inputs = {
{fruit = 2}
},
outputs = {jam = 3}
},
city =
{
sprite = 5,
inputs = {},
outputs = {}
},
}
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, building)
local worldtile = {}
worldtile.x = x
worldtile.y = y
worldtile.building = building
worldtile.draw = function(this)
spr(worldtile.bulding.sprite,worldtile.x*2*8,8+worldtile.y*2*8, 2, 2)
end
worldtile.compute_effet = function(this)
for _,input in pairs(worldtile.building.inputs) do
--input.
end
end
return worldtile
end