saute avec PICO8
function _init()
ball = {
x = 60,
y = 60,
vy = 0,
terre = true
}
end
function _update()
-- Déplacement horizontal
if btn(0) then ball.x += 2 end -- Droite
if btn(1) then ball.x -= 2 end -- Gauche
-- Déplacement vertical manuel (optionnel)
if btn(2) then ball.y -= 2 end -- Haut
if btn(3) then ball.y += 2 end -- Bas
-- Saut
if ball.terre and btnp(4) then -- Bouton "X" (4 en Pico-8)
ball.vy = -4
ball.terre = false
end
-- Gravité
if not ball.terre then
ball.vy = ball.vy + 0.3
ball.y = ball.y + ball.vy
-- Collision avec le sol (ex: y = 60)
if ball.y >= 60 then
ball.y = 60
ball.terre = true
ball.vy = 0
end
end
end
function _draw()
cls()
spr(1, ball.x, ball.y) -- Assure-toi que le sprite 1 existe
end