Compare commits

...

2 Commits

Author SHA1 Message Date
dbd617d849 persecucion_mortal.lua: pasado a "objetos" 2023-09-11 08:23:57 +02:00
f07bd0c116 space.lua: cambiado setmode a mode 2023-09-11 08:22:17 +02:00
2 changed files with 80 additions and 1 deletions

View File

@@ -0,0 +1,79 @@
jugador = {
x = 0,
y = 0,
vx = 1,
vy = 1,
color = COLOR_YELLOW,
color_fondo = COLOR_RED,
sprite = chr(250),
comptador = 0,
actualitza = function(self)
self.comptador = self.comptador + 1
self:anima()
self:mou()
self:comprova_bordes()
end,
mou = function(self)
if self.comptador % 30 == 0 then
self.x = self.x + self.vx
self.y = self.y + self.vy
end
end,
comprova_bordes = function (self)
if self.x > pantalla_borde_dret then
self.vx = self.vx * -1
self.x = pantalla_borde_dret
end
if self.x < pantalla_borde_esquerre then
self.vx = self.vx * -1
self.x = pantalla_borde_esquerre
end
if self.y > pantalla_borde_baix then
self.vy = self.vy * -1
self.y = pantalla_borde_baix
end
if self.y < pantalla_borde_dalt then
self.vy = self.vy * -1
self.y = pantalla_borde_dalt
end
end,
dibuixa = function(self)
paper(self.color_fondo)
ink(self.color)
print(self.sprite, self.x, self.y)
end,
anima = function(self)
if self.comptador % 60 < 30 then
self.sprite = chr(250)
else
self.sprite = chr(251)
end
end
}
pantalla_borde_dalt = 0
pantalla_borde_baix = 29
pantalla_borde_esquerre = 0
pantalla_borde_dret = 39
function init()
mode(1)
paper(COLOR_BLACK)
ink(COLOR_RED)
end
function update()
jugador:actualitza()
paper(COLOR_RED)
cls()
jugador:dibuixa()
end

View File

@@ -197,7 +197,7 @@ function draw_debug()
end
function init()
setmode(2)
mode(2)
clock = 0
score = 0
paper(COLOR_BLACK)