space.lua: cambiado setmode a mode

This commit is contained in:
2023-09-11 08:22:17 +02:00
parent 2cf9dd1921
commit f07bd0c116
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
}
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

View File

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