- Canvis en tools/spritedit.lua, crec
This commit is contained in:
39
game.lua
39
game.lua
@@ -1,34 +1,5 @@
|
|||||||
Persona = {
|
a=32
|
||||||
name = "---",
|
hex=string.format("%02X",a)
|
||||||
}
|
print(hex)
|
||||||
|
b=tonumber(hex,16)
|
||||||
function Persona:SayName()
|
print(b)
|
||||||
print(self.name .. " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
function Persona:new(obj)
|
|
||||||
obj = obj or {}
|
|
||||||
setmetatable(obj, self)
|
|
||||||
--self.__index = self
|
|
||||||
return obj
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function init()
|
|
||||||
mode(0)
|
|
||||||
cls()
|
|
||||||
Persona.__index=Persona
|
|
||||||
persones={}
|
|
||||||
persones[1] = Persona:new({name="Persona1"})
|
|
||||||
persones[2] = Persona:new({name="Persona2"})
|
|
||||||
persones[3] = Persona:new({name="Persona3"})
|
|
||||||
persones[4] = Persona:new({name="Persona4"})
|
|
||||||
|
|
||||||
for i,v in ipairs(persones) do
|
|
||||||
v:SayName()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function update()
|
|
||||||
end
|
|
||||||
@@ -2,26 +2,43 @@ function init()
|
|||||||
ink_color = 15
|
ink_color = 15
|
||||||
paper_color = 0
|
paper_color = 0
|
||||||
setchar(0,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff)
|
setchar(0,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff)
|
||||||
sprite={0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03}
|
sprite={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
|
||||||
|
--0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
|
||||||
|
--0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
||||||
|
--0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
|
||||||
|
--0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03}
|
||||||
end
|
end
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
|
-- Borra pantalla
|
||||||
color(15,1)
|
color(15,1)
|
||||||
cls()
|
cls()
|
||||||
|
|
||||||
|
-- Pinta sprite en gran a pantalla
|
||||||
color(ink_color,paper_color)
|
color(ink_color,paper_color)
|
||||||
drawbigspr(sprite,1,1)
|
drawbigspr(sprite,1,1)
|
||||||
|
|
||||||
|
-- Pinta el sprite en els caracters A, B, C i D
|
||||||
drawspr(sprite,65)
|
drawspr(sprite,65)
|
||||||
|
|
||||||
|
-- Pinta els caracters AB CD a pantalla
|
||||||
print("AB",18,1) print("CD",18,2)
|
print("AB",18,1) print("CD",18,2)
|
||||||
|
|
||||||
|
-- Pinta la paleta
|
||||||
for i=0,15 do
|
for i=0,15 do
|
||||||
color(0,i)
|
color(0,i)
|
||||||
poke(721+i,0) poke(1921+i,i<<4)
|
poke(721+i,0) poke(1921+i,i<<4)
|
||||||
poke(761+i,0) poke(1961+i,i<<4)
|
poke(761+i,0) poke(1961+i,i<<4)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Pinta el borde roig a les entrades en la paleta seleccionades
|
||||||
poke(1921+ink_color, peek(1921+ink_color)+4)
|
poke(1921+ink_color, peek(1921+ink_color)+4)
|
||||||
poke(1961+paper_color, peek(1961+paper_color)+4)
|
poke(1961+paper_color, peek(1961+paper_color)+4)
|
||||||
|
|
||||||
|
-- Gestió dels clicks en la paleta
|
||||||
if mousebutton(1) and mousex()>=1 and mousey()>=18 and mousex()<=16 and mousey()<=19 then
|
if mousebutton(1) and mousex()>=1 and mousey()>=18 and mousex()<=16 and mousey()<=19 then
|
||||||
if mousey()==18 then
|
if mousey()==18 then
|
||||||
ink_color = mousex()-1
|
ink_color = mousex()-1
|
||||||
@@ -30,7 +47,15 @@ function update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Gestió dels clicks sobre l'sprite
|
||||||
handlesprmouse()
|
handlesprmouse()
|
||||||
|
|
||||||
|
-- Si pulsem 'C', borrar el sprite
|
||||||
|
if btnp(KEY_C) then
|
||||||
|
for i=1,32 do
|
||||||
|
sprite[i]=0;
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mousepressed = false
|
mousepressed = false
|
||||||
|
|||||||
Reference in New Issue
Block a user