diff --git a/game.lua b/game.lua index dfd9a60..ce7d8a0 100644 --- a/game.lua +++ b/game.lua @@ -1,34 +1,5 @@ -Persona = { - name = "---", -} - -function Persona:SayName() - 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 \ No newline at end of file +a=32 +hex=string.format("%02X",a) +print(hex) +b=tonumber(hex,16) +print(b) \ No newline at end of file diff --git a/tools/spritedit.lua b/tools/spritedit.lua index f373c72..c97a8e1 100644 --- a/tools/spritedit.lua +++ b/tools/spritedit.lua @@ -2,26 +2,43 @@ function init() ink_color = 15 paper_color = 0 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 function update() + -- Borra pantalla color(15,1) cls() + + -- Pinta sprite en gran a pantalla color(ink_color,paper_color) drawbigspr(sprite,1,1) + + -- Pinta el sprite en els caracters A, B, C i D drawspr(sprite,65) + + -- Pinta els caracters AB CD a pantalla print("AB",18,1) print("CD",18,2) + -- Pinta la paleta for i=0,15 do color(0,i) poke(721+i,0) poke(1921+i,i<<4) poke(761+i,0) poke(1961+i,i<<4) end + -- Pinta el borde roig a les entrades en la paleta seleccionades poke(1921+ink_color, peek(1921+ink_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 mousey()==18 then ink_color = mousex()-1 @@ -30,7 +47,15 @@ function update() end end + -- Gestió dels clicks sobre l'sprite handlesprmouse() + + -- Si pulsem 'C', borrar el sprite + if btnp(KEY_C) then + for i=1,32 do + sprite[i]=0; + end + end end mousepressed = false