input refactor

This commit is contained in:
Turanszki Janos
2019-11-23 04:33:03 +00:00
parent df963528da
commit fbb53e3a6d
30 changed files with 1153 additions and 1044 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ end
runProcess(function()
while true do
if(input.Press(VK_F8)) then
if(input.Press(KEYBOARD_BUTTON_F8)) then
ToggleCameraAnimation()
end
if(play) then
+1 -1
View File
@@ -39,7 +39,7 @@ end
runProcess(function()
while true do
if(input.Press(VK_F8)) then
if(input.Press(KEYBOARD_BUTTON_F8)) then
ToggleCameraAnimation()
end
if(play) then
+8 -8
View File
@@ -95,17 +95,17 @@ Character = {
if(self.state==self.states.STAND) then
local lookDir = Vector()
if(input.Down(VK_LEFT) or input.Down(string.byte('A'))) then
if(input.Down(KEYBOARD_BUTTON_LEFT) or input.Down(string.byte('A'))) then
lookDir = lookDir:Add( Vector(-1) )
end
if(input.Down(VK_RIGHT) or input.Down(string.byte('D'))) then
if(input.Down(KEYBOARD_BUTTON_RIGHT) or input.Down(string.byte('D'))) then
lookDir = lookDir:Add( Vector(1) )
end
if(input.Down(VK_UP) or input.Down(string.byte('W'))) then
if(input.Down(KEYBOARD_BUTTON_UP) or input.Down(string.byte('W'))) then
lookDir = lookDir:Add( Vector(0,0,1) )
end
if(input.Down(VK_DOWN) or input.Down(string.byte('S'))) then
if(input.Down(KEYBOARD_BUTTON_DOWN) or input.Down(string.byte('S'))) then
lookDir = lookDir:Add( Vector(0,0,-1) )
end
@@ -113,7 +113,7 @@ Character = {
lookDir = vector.Add(lookDir, Vector(analog.GetX(), 0, analog.GetY()))
if(lookDir:Length()>0) then
if(input.Down(VK_LSHIFT) or input.Down(GAMEPAD_BUTTON_6, INPUT_TYPE_GAMEPAD)) then
if(input.Down(KEYBOARD_BUTTON_LSHIFT) or input.Down(GAMEPAD_BUTTON_6)) then
self:MoveDirection(lookDir,self.moveSpeed*2)
else
self:MoveDirection(lookDir,self.moveSpeed)
@@ -122,7 +122,7 @@ Character = {
end
if( input.Press(string.byte('J')) or input.Press(VK_SPACE) or input.Press(GAMEPAD_BUTTON_2, INPUT_TYPE_GAMEPAD) ) then
if( input.Press(string.byte('J')) or input.Press(KEYBOARD_BUTTON_SPACE) or input.Press(GAMEPAD_BUTTON_2) ) then
self:Jump(2000)
end
@@ -133,7 +133,7 @@ Character = {
diff = vector.Multiply(diff, getDeltaTime() * 4)
-- read from mouse:
if(input.Down(VK_RBUTTON)) then
if(input.Down(MOUSE_BUTTON_RIGHT)) then
local mousePosNew = input.GetPointer()
local mouseDif = vector.Subtract(mousePosNew,self.savedPointerPos)
mouseDif = mouseDif:Multiply(getDeltaTime() * 0.3)
@@ -379,7 +379,7 @@ runProcess(function()
if(input.Press(VK_ESCAPE)) then
if(input.Press(KEYBOARD_BUTTON_ESCAPE)) then
-- restore previous component
-- so if you loaded this script from the editor, you can go back to the editor with ESC
backlog_post("EXIT")
+11 -11
View File
@@ -1428,15 +1428,15 @@ local function Character(face, skin_color, shirt_color, hair_color, shoe_color)
Input = function(self, playerindex)
-- read input:
local left = input.Down(string.byte('A'), INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_LEFT, INPUT_TYPE_GAMEPAD, playerindex)
local right = input.Down(string.byte('D'), INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_RIGHT, INPUT_TYPE_GAMEPAD, playerindex)
local up = input.Down(string.byte('W'), INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_UP, INPUT_TYPE_GAMEPAD, playerindex)
local down = input.Down(string.byte('S'), INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_DOWN, INPUT_TYPE_GAMEPAD, playerindex)
local A = input.Down(VK_RIGHT, INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_3, INPUT_TYPE_GAMEPAD, playerindex)
local B = input.Down(VK_UP, INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_4, INPUT_TYPE_GAMEPAD, playerindex)
local C = input.Down(VK_LEFT, INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_1, INPUT_TYPE_GAMEPAD, playerindex)
local D = input.Down(VK_DOWN, INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_2, INPUT_TYPE_GAMEPAD, playerindex)
local T = input.Down(string.byte('T'), INPUT_TYPE_KEYBOARD, playerindex) or input.Down(GAMEPAD_BUTTON_5, INPUT_TYPE_GAMEPAD, playerindex)
local left = input.Down(string.byte('A'), playerindex) or input.Down(GAMEPAD_BUTTON_LEFT, playerindex)
local right = input.Down(string.byte('D'), playerindex) or input.Down(GAMEPAD_BUTTON_RIGHT, playerindex)
local up = input.Down(string.byte('W'), playerindex) or input.Down(GAMEPAD_BUTTON_UP, playerindex)
local down = input.Down(string.byte('S'), playerindex) or input.Down(GAMEPAD_BUTTON_DOWN, playerindex)
local A = input.Down(KEYBOARD_BUTTON_RIGHT, playerindex) or input.Down(GAMEPAD_BUTTON_3, playerindex)
local B = input.Down(KEYBOARD_BUTTON_UP, playerindex) or input.Down(GAMEPAD_BUTTON_4, playerindex)
local C = input.Down(KEYBOARD_BUTTON_LEFT, playerindex) or input.Down(GAMEPAD_BUTTON_1, playerindex)
local D = input.Down(KEYBOARD_BUTTON_DOWN, playerindex) or input.Down(GAMEPAD_BUTTON_2, playerindex)
local T = input.Down(string.byte('T'), playerindex) or input.Down(GAMEPAD_BUTTON_5, playerindex)
-- swap left and right if facing the opposite side:
if(self.face < 0) then
@@ -1946,7 +1946,7 @@ runProcess(function()
player2.ai_state = "Attack"
elseif(input.Press(string.byte('H'))) then
debug_draw = not debug_draw
elseif(input.Press(GAMEPAD_BUTTON_10, INPUT_TYPE_GAMEPAD, 1)) then
elseif(input.Press(GAMEPAD_BUTTON_10, 1)) then
if(player2_control == "CPU") then
player2_control = "Controller2"
else
@@ -1984,7 +1984,7 @@ runProcess(function()
update()
if(input.Press(VK_ESCAPE)) then
if(input.Press(KEYBOARD_BUTTON_ESCAPE)) then
-- restore previous component
-- so if you loaded this script from the editor, you can go back to the editor with ESC
backlog_post("EXIT")