[NEW] Controller.lua - Gestiona tot lo relatiu al teclat i gamepad
[NEW] opcions_input.lua - Pantalla de definició de tecles per a teclat i pad - Modificat el abad per a que use controller
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
-- TO DO: Afegir un contador per a saber quan de temps está parat el abad per a traure al Imp
|
||||
keysdown = {}
|
||||
-- local arcade_config = require("arcade_config")
|
||||
cw = arcade_config.character_width
|
||||
ch = arcade_config.character_height
|
||||
@@ -307,34 +305,23 @@ function abad_state_normal()
|
||||
|
||||
abad_make_safe()
|
||||
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
if controller:check("right") then
|
||||
abad.update=abad_state_walking
|
||||
abad.flip=false
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
elseif controller:check("left") then
|
||||
abad.update=abad_state_walking
|
||||
abad.flip=true
|
||||
elseif key.down(keyJump) or pad.down(btnJump) then
|
||||
elseif controller:check("jump") then
|
||||
abad_do_jump()
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
elseif controller:check("down") then
|
||||
abad.update=abad_state_crouch
|
||||
--elseif btn(KEY_Z) then
|
||||
-- abad.respawning=240
|
||||
elseif key_release(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
|
||||
elseif controller:check("shoot") then
|
||||
abad_shot_cacau()
|
||||
end
|
||||
end
|
||||
|
||||
function key_release(keyid)
|
||||
-- if keysdown[keyid] then print("Pressed "..keyid) end
|
||||
if key.down(keyid) then
|
||||
keysdown[keyid] = true
|
||||
elseif keysdown[keyid] then
|
||||
keysdown[keyid] = false
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function abad_state_crouch()
|
||||
abad.bb.y=8
|
||||
abad.bb.h=24
|
||||
@@ -343,7 +330,7 @@ function abad_state_crouch()
|
||||
abad.step=0
|
||||
abad.jumpfwd=false
|
||||
abad.jump_height=0
|
||||
if not (key.down(keyDown) or pad.down(btnDown)) then
|
||||
if not controller:check("down") then
|
||||
abad.update=abad_state_normal
|
||||
abad.bb.y=0
|
||||
abad.bb.h=32
|
||||
@@ -393,19 +380,19 @@ function abad_state_walking()
|
||||
abad_make_safe()
|
||||
|
||||
-- Gestionar accions mentre es camina
|
||||
if key.down(keyJump) or pad.down(btnJump) then
|
||||
if controller:check("jump") then
|
||||
abad_do_jump(true); -- jumping forward
|
||||
return
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
elseif controller:check("down") then
|
||||
abad.update=abad_state_crouch
|
||||
elseif key.down(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
|
||||
elseif controller:check("shoot") then
|
||||
abad_shot_cacau()
|
||||
end
|
||||
|
||||
-- "Flipar" a l'Abad
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
if controller:check("right") then
|
||||
abad.flip=false
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
elseif controller:check("left") then
|
||||
abad.flip=true
|
||||
elseif abad.wait==0 then
|
||||
abad.update=abad_state_normal
|
||||
@@ -477,21 +464,21 @@ function abad_state_stairs()
|
||||
local x2_check = abad.x+abad.bb.x+abad.bb.w-1
|
||||
local y_check = abad.y+abad.bb.h-1
|
||||
|
||||
if key.down(keyRight) or pad.down(btnRight) then
|
||||
if controller:check("right") then
|
||||
abad.flip=false
|
||||
abad_advance()
|
||||
if abad.wait==6 then sound.play(audio_low) end
|
||||
elseif key.down(keyLeft) or pad.down(btnLeft) then
|
||||
elseif controller:check("left") then
|
||||
abad.flip=true
|
||||
abad_advance()
|
||||
if abad.wait==6 then sound.play(audio_low) end
|
||||
elseif key.down(keyUp) or pad.down(btnUp) then
|
||||
elseif controller:check("up") then
|
||||
if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
||||
arc_check_tile(x2_check,y_check)==tiletype.stair then
|
||||
abad.y=abad.y-1
|
||||
if abad.wait==6 then sound.play(audio_low) end
|
||||
end
|
||||
elseif key.down(keyDown) or pad.down(btnDown) then
|
||||
elseif controller:check("down") then
|
||||
if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
||||
arc_check_tile(x2_check,y_check)==tiletype.stair then
|
||||
abad.y=abad.y+1
|
||||
|
||||
Reference in New Issue
Block a user