mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Update virtual control stuff
This commit is contained in:
68
main.lua
68
main.lua
@@ -7,7 +7,7 @@ else
|
||||
end
|
||||
|
||||
require 'funcs'
|
||||
DEBUG_showKey=true
|
||||
DEBUG_showKey=false
|
||||
|
||||
PENTO_MODE = false
|
||||
|
||||
@@ -27,11 +27,12 @@ function love.load()
|
||||
require "load.sounds"
|
||||
require "load.save"
|
||||
require "load.bigint"
|
||||
loadSave()
|
||||
require "scene"
|
||||
require "game.vctrl" -- VCTRL
|
||||
|
||||
-- love.mouse.setVisible(false)
|
||||
|
||||
scene = config.firstTime and InputConfigScene() or TitleScene()
|
||||
|
||||
love.mouse.setVisible(false)
|
||||
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
||||
|
||||
GLOBAL_TRANSFORM = love.math.newTransform()
|
||||
@@ -42,14 +43,22 @@ function love.load()
|
||||
love.window.setFullscreen(config["fullscreen"])
|
||||
|
||||
VCTRL.new{
|
||||
{type='button',x= 100,y=320,icon= 'up',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x= 160,y=380,icon= 'right',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x= 100,y=440,icon= 'down',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x= 40,y=380,icon= 'left',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x=640-100,y=320,icon='rotate_right2',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x=640-160,y=380,icon= 'rotate_left2',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x=640-100,y=440,icon= 'rotate_right',r=30,iconSize=60,alpha=1},
|
||||
{type='button',x=640- 40,y=380,icon= 'rotate_left',r=30,iconSize=60,alpha=1},
|
||||
-- {type='button',x= 100,y=320,key= 'up',icon= 'up',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x= 160,y=380,key='right',icon= 'right',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x= 100,y=440,key= 'down',icon= 'down',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x= 40,y=380,key= 'left',icon= 'left',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x=640-100,y=320,key= 'f16',icon='rotate_right2',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x=640-160,y=380,key= 'f14',icon= 'rotate_left2',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x=640-100,y=440,key= 'f15',icon= 'rotate_right',r=35,iconSize=60,alpha=1},
|
||||
-- {type='button',x=640- 40,y=380,key= 'f13',icon= 'rotate_left',r=35,iconSize=60,alpha=1},
|
||||
{type='button',x= 70,y=280,key= 'up',icon= 'up',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x= 145,y=355,key='right',icon= 'right',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x= 70,y=430,key= 'down',icon= 'down',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x= -5,y=355,key= 'left',icon= 'left',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x=640- 70,y=280,key= 'f16',icon='rotate_right2',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x=640-145,y=355,key= 'f14',icon= 'rotate_left2',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x=640- 70,y=430,key= 'f15',icon= 'rotate_right',r=45,iconSize=60,alpha=1},
|
||||
{type='button',x=640- -5,y=355,key= 'f13',icon= 'rotate_left',r=45,iconSize=60,alpha=1},
|
||||
}
|
||||
end
|
||||
|
||||
@@ -71,9 +80,6 @@ function love.draw()
|
||||
scene:render()
|
||||
VCTRL.draw()
|
||||
|
||||
love.graphics.setLineWidth(3)
|
||||
love.graphics.rectangle('line',0,0,640,480)
|
||||
|
||||
-- -- Grid system
|
||||
-- love.graphics.replaceTransform(GLOBAL_TRANSFORM)
|
||||
|
||||
@@ -95,12 +101,25 @@ function love.draw()
|
||||
end
|
||||
end
|
||||
|
||||
function love.mousepressed(x,y,id)
|
||||
local return_scancode, escape_scancode = love.keyboard.getScancodeFromKey('return'), love.keyboard.getScancodeFromKey('escape')
|
||||
function love.touchpressed(id,x,y)
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
VCTRL.press(x,y,id)
|
||||
if not VCTRL.press(x,y,id) then
|
||||
if x >= 320 and x <= 640 then
|
||||
love.keypressed('escape', escape_scancode)
|
||||
elseif x >= 0 and x <= 320 then
|
||||
love.keypressed('return', return_scancode)
|
||||
end
|
||||
end
|
||||
end
|
||||
function love.mousereleased(x,y,id)
|
||||
VCTRL.release(id)
|
||||
function love.touchreleased(id,x,y)
|
||||
if not VCTRL.release(id) then
|
||||
if x >= 320 and x <= 640 then
|
||||
love.keyreleased('escape', escape_scancode)
|
||||
elseif x >= 0 and x <= 320 then
|
||||
love.keyreleased('return', return_scancode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function love.keypressed(key, scancode)
|
||||
@@ -109,12 +128,11 @@ function love.keypressed(key, scancode)
|
||||
-- global hotkeys
|
||||
if scancode == "f4" then
|
||||
config["fullscreen"] = not config["fullscreen"]
|
||||
saveConfig()
|
||||
love.window.setFullscreen(config["fullscreen"])
|
||||
elseif scancode == "f2" and scene.title ~= "Input Config" and scene.title ~= "Game" then
|
||||
scene = InputConfigScene()
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||
return
|
||||
-- escape is reserved for menu_back
|
||||
elseif scancode == "escape" or scancode == "acback" then
|
||||
@@ -137,7 +155,7 @@ function love.keyreleased(key, scancode)
|
||||
if scancode == "escape" or scancode == 'acback' then
|
||||
scene:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||
return
|
||||
-- handle all other keys; tab is reserved, but the input config scene keeps it from getting configured as a game input, so pass tab to the scene here
|
||||
else
|
||||
@@ -201,12 +219,6 @@ function love.joystickaxis(joystick, axis, value)
|
||||
end
|
||||
end
|
||||
|
||||
function love.touchpressed()
|
||||
love.keyboard.setKeyRepeat(true)
|
||||
love.keyboard.setTextInput(false)
|
||||
love.keyboard.setTextInput(true)
|
||||
end
|
||||
|
||||
local last_hat_direction = ""
|
||||
local directions = {
|
||||
["u"] = "up",
|
||||
|
||||
Reference in New Issue
Block a user