space.lua: cambiado setmode a mode
This commit is contained in:
79
persecucion_mortal/persecucion_mortal.lua
Normal file
79
persecucion_mortal/persecucion_mortal.lua
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
actualitza_jugador()
|
||||||
|
|
||||||
|
paper(COLOR_RED)
|
||||||
|
cls()
|
||||||
|
dibuixa_jugador()
|
||||||
|
end
|
||||||
|
|
||||||
|
function actualitza_jugador()
|
||||||
|
jugador.comptador = jugador.comptador + 1
|
||||||
|
anima_jugador()
|
||||||
|
mou_jugador()
|
||||||
|
comprova_bordes_jugador()
|
||||||
|
end
|
||||||
|
|
||||||
|
function mou_jugador()
|
||||||
|
if jugador.comptador % 30 == 0 then
|
||||||
|
jugador.x = jugador.x + jugador.vx
|
||||||
|
jugador.y = jugador.y + jugador.vy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function comprova_bordes_jugador()
|
||||||
|
if jugador.x > pantalla_borde_dret then
|
||||||
|
jugador.vx = jugador.vx * -1
|
||||||
|
jugador.x = pantalla_borde_dret
|
||||||
|
end
|
||||||
|
|
||||||
|
if jugador.x < pantalla_borde_esquerre then
|
||||||
|
jugador.vx = jugador.vx * -1
|
||||||
|
jugador.x = pantalla_borde_esquerre
|
||||||
|
end
|
||||||
|
|
||||||
|
if jugador.y > pantalla_borde_baix then
|
||||||
|
jugador.vy = jugador.vy * -1
|
||||||
|
jugador.y = pantalla_borde_baix
|
||||||
|
end
|
||||||
|
|
||||||
|
if jugador.y < pantalla_borde_dalt then
|
||||||
|
jugador.vy = jugador.vy * -1
|
||||||
|
jugador.y = pantalla_borde_dalt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dibuixa_jugador()
|
||||||
|
paper(jugador.color_fondo)
|
||||||
|
ink(jugador.color)
|
||||||
|
print(jugador.sprite, jugador.x, jugador.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function anima_jugador()
|
||||||
|
if jugador.comptador % 60 < 30 then
|
||||||
|
jugador.sprite = chr(250)
|
||||||
|
else
|
||||||
|
jugador.sprite = chr(251)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -197,7 +197,7 @@ function draw_debug()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
setmode(2)
|
mode(2)
|
||||||
clock = 0
|
clock = 0
|
||||||
score = 0
|
score = 0
|
||||||
paper(COLOR_BLACK)
|
paper(COLOR_BLACK)
|
||||||
|
|||||||
Reference in New Issue
Block a user