- [NEW] Ja va amb gamepad

This commit is contained in:
2025-06-26 06:45:52 +02:00
parent e456f0f781
commit 47c7edde46

View File

@@ -120,7 +120,7 @@ sprites = {
anim = "hero_stairs_idle"
move_anim = "hero_stairs"
-- SI PULSA AMUNT...
if key.down(key.UP) then
if key.down(key.UP) or pad.down(pad.UP) then
anim = move_anim
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3
if map.tile(tx1,ty) < 16 or map.tile(tx2,ty) < 16 then
@@ -131,7 +131,7 @@ sprites = {
end
end
-- SI PULSA AVALL...
elseif key.down(key.DOWN) then
elseif key.down(key.DOWN) or pad.down(pad.DOWN) then
anim = move_anim
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then
@@ -160,7 +160,7 @@ sprites = {
anim = "hero_stand"
-- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL...
if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then
if key.down(key.DOWN) then
if key.down(key.DOWN) or pad.down(pad.DOWN) then
anim = "hero_stairs"
--local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
--if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then
@@ -170,14 +170,14 @@ sprites = {
end
end
-- SI POLSA SPACE...
if key.down(key.SPACE) then
if key.down(key.SPACE) or pad.down(pad.A) then
sprites.hero.jumping = 17
end
end
end
end
-- ESTIGA COM ESTIGA, SI POLSA ESQUERRA O DRETA...
if key.down(key.LEFT) then
if key.down(key.LEFT) or pad.down(pad.LEFT) then
sprites.hero.flipped = true
anim = move_anim
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
@@ -188,7 +188,7 @@ sprites = {
sprites.hero.pos.x = sprites.hero.pos.x - 1
end
end
elseif key.down(key.RIGHT) then
elseif key.down(key.RIGHT) or pad.down(pad.RIGHT) then
sprites.hero.flipped = false
anim = move_anim
local tx, ty = (sprites.hero.pos.x+12)>>3, (sprites.hero.pos.y+16)>>3