- [NEW] Ara cada actor pot tindre la seua propia surface.

- [WRK] Treballant en el editor de jailmojis.
This commit is contained in:
2025-06-03 14:01:39 +02:00
parent 145d5b09d4
commit 99f3648d08
6 changed files with 173 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 484 B

BIN
data/actor-hair.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

View File

@@ -3,14 +3,22 @@ actors={
updating=false,
main={},
under_cursor="",
surface=0,
should_free_surf=false,
init=function()
for i,actor in ipairs(actors.list) do
if actor.should_free_surf then
surf.free(actor.surface)
end
end
actors.list={}
actors.updating=false
end,
add=function(actor)
actor.dx,actor.dy=0,0
actor.surface=surf.load("sprites.gif")
table.insert(actors.list, actor)
end,
@@ -61,6 +69,7 @@ actors={
pal.subpal(1,16,8)
end
surf.source(v.surface)
if v.o=='u' then
draw.surf(v.gfx.x+frame,v.gfx.y+16,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,v.dy>1)
elseif v.o=='d' then

View File

@@ -1,3 +1,159 @@
jailmoji={
surface=-1,
gendata={},
generate=function(genstring)
if genstring then
for i=1,#genstring do jailmoji.gendata[i]=genstring:byte(i)-65 end
end
local surf_base = surf.load("actor-base.gif")
local surf_hair = surf.load("actor-hair.gif")
if jailmoji.surface ~= -1 then surf.free(jailmoji.surface) end
jailmoji.surface = surf.new(32,48)
surf.target(jailmoji.surface)
pal.subpal(20,jailmoji.gendata[2]+1) -- vestit1
pal.subpal(21,jailmoji.gendata[3]+1) -- vestit2
pal.subpal(22,jailmoji.gendata[4]+1) -- sabates
pal.subpal(24,jailmoji.gendata[5]+1) -- pell1
pal.subpal(25,jailmoji.gendata[6]+1) -- pell2
pal.subpal(23,jailmoji.gendata[15]+1) -- monyo
pal.subpal(26,jailmoji.gendata[11]+1) -- ulls
surf.source(surf_base)
draw.surf(0,0,32,48,0,0)
surf.source(surf_hair)
local dx=jailmoji.gendata[1]*16
draw.surf(dx,0,16,48,0,0)
draw.surf(dx,0,16,48,16,1)
pal.subpal()
surf.target(0)
end,
editor={
old_update=nil,
view=0,
animated=false,
changed=false,
show=function()
jailmoji.editor.old_update=update
update=jailmoji.editor.update
--jailmoji.surface = surf.load("actor-base.gif")
jailmoji.generate("AABJONAAAAAAAAAAA")
end,
text_button=function(x, y, label, current_value, own_value)
local rect,color = draw.rect, 8
local mx,my = mouse.pos()
if current_value==own_value then rect,color = draw.rectf, 5 else rect,color = draw.rect, 8 end
rect(x,y,9,9,8)
draw.text(label,x+3,y+2,color)
if mx>=x and mx<x+9 and my>=y and my<y+9 and mouse.press(mouse.LEFT) then return own_value end
return current_value
end,
spin_button=function(x, y, current_value, max_value)
local rect,color = draw.rect, 8
local mx,my = mouse.pos() mx,my = view.tolocal(mx,my)
local hover = mx>=x and mx<x+9 and my>=y and my<y+9
local clicked = hover and mouse.down(mouse.LEFT)
local label = string.char(current_value + 65)
if clicked then rect,color = draw.rectf, 5 else rect,color = draw.rect, 8 end
rect(x,y,9,9,8)
draw.text(label,x+3,y+2,color)
if hover and mouse.press(mouse.LEFT) then
jailmoji.editor.changed = true
if current_value+1 > max_value then
return 0
else
return current_value+1
end
end
return current_value
end,
color_button=function(x, y, current_value)
local c1,c2,c3 = current_value+1,6,8
local mx,my = mouse.pos() mx,my = view.tolocal(mx,my)
local hover = mx>=x and mx<x+9 and my>=y and my<y+9
local clicked = hover and mouse.down(mouse.LEFT)
if clicked then c1,c2,c3 = 6,6,8 end
draw.rectf(x,y,9,9,c1) draw.rect(x+1,y+1,7,7,c2) draw.rect(x,y,9,9,c3)
if hover and mouse.press(mouse.LEFT) then
jailmoji.editor.changed = true
if current_value+1 > 15 then
return 0
else
return current_value+1
end
end
return current_value
end,
update=function()
local self = jailmoji.editor
draw.rectf(10,10, 140, 120,5)
draw.rect(10,10, 140, 120,8)
draw.text("JAILMOJI EDITOR",20,14,8)
draw.rectf(19,23, 50, 50,7)
draw.rect(19,23, 50, 50,8)
surf.source(jailmoji.surface)
local vx = 0 if self.animated then vx = 16 end
local vy = self.view * 16
draw.surf(vx,vy,16,16,28,32,32,32)
local rect,color = draw.rect, 8
local mx,my = mouse.pos()
self.view=self.text_button(19,74,"F",self.view, 0)
self.view=self.text_button(29,74,"B",self.view, 1)
self.view=self.text_button(39,74,"S",self.view, 2)
self.animated=self.text_button(60,74,"A",self.animated, not self.animated)
view.origin(-70,-23)
draw.text("Vestit:",1,2,8)
jailmoji.gendata[1] = self.spin_button(28,0,jailmoji.gendata[1],10)
jailmoji.gendata[2] = self.color_button(38,0,jailmoji.gendata[2])
jailmoji.gendata[3] = self.color_button(48,0,jailmoji.gendata[3])
jailmoji.gendata[4] = self.color_button(58,0,jailmoji.gendata[4])
draw.text("Pell:",1,12,8)
jailmoji.gendata[5] = self.color_button(28,10,jailmoji.gendata[5])
jailmoji.gendata[6] = self.color_button(38,10,jailmoji.gendata[6])
draw.text("Cara:",1,22,8)
jailmoji.gendata[7] = self.spin_button(28,20,jailmoji.gendata[7],10)
jailmoji.gendata[8] = self.spin_button(38,20,jailmoji.gendata[8],10)
jailmoji.gendata[9] = self.spin_button(48,20,jailmoji.gendata[9],10)
draw.text("Ulls:",1,32,8)
jailmoji.gendata[10] = self.spin_button(28,30,jailmoji.gendata[10],10)
jailmoji.gendata[11] = self.color_button(38,30,jailmoji.gendata[11])
jailmoji.gendata[12] = self.spin_button(48,30,jailmoji.gendata[12],10)
jailmoji.gendata[13] = self.color_button(58,30,jailmoji.gendata[13])
draw.text("Monyo:",1,42,8)
jailmoji.gendata[14] = self.spin_button(28,40,jailmoji.gendata[14],10)
jailmoji.gendata[15] = self.color_button(38,40,jailmoji.gendata[15])
draw.text("Motxilla:",1,52,8)
jailmoji.gendata[16] = self.spin_button(38,50,jailmoji.gendata[16],10)
jailmoji.gendata[17] = self.color_button(48,50,jailmoji.gendata[17])
view.origin(0,0)
if jailmoji.editor.changed then
jailmoji.editor.changed = false
jailmoji.generate()
end
end,
},
}

View File

@@ -2,6 +2,7 @@ require "fade"
require "game"
require "editor"
require "menu"
require "jailmoji"
function mini.init()
menu_option=0
@@ -35,7 +36,11 @@ end
function main_init()
--set_update(menu_update)
second_menu = {{"PEIV", function() end},{"TORNAR",show_main_menu}}
main_menu = { {"JUGAR", game.restart}, {"EDITOR", editor.init}, {"EIXIR", sys.quit}, {"TEST", function() menu.show(second_menu) end } }
main_menu = { {"JUGAR", game.restart},
{"EDITOR", editor.init},
{"JAILMOJI", jailmoji.editor.show},
{"EIXIR", sys.quit},
{"TEST", function() menu.show(second_menu) end } }
show_main_menu()
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB