diff --git a/src/Draw.lua b/src/Draw.lua index c0cf5d7..c87a30b 100755 --- a/src/Draw.lua +++ b/src/Draw.lua @@ -22,7 +22,7 @@ function love.draw() if displayingTitleScreen then drawTitleScreen() elseif displayingControls then - drawControlScreen() + drawControlScreen() else love.graphics.setColor(255,255,255,255) @@ -87,6 +87,36 @@ function love.draw() love.graphics.draw(canvas2X,borderX,borderY) love.graphics.scale(1.0/graphicsScaleFactor,1.0/graphicsScaleFactor) end + -- draw the virtual gamepad directly to the screen + if touching then + -- virtual gamepad button coordinates i,j (1,1) top left, (3,3) bottom right + love.graphics.setColor(255,255,255,128) + local width = love.graphics.getWidth() + local height = love.graphics.getHeight() + local dPadButtonSizeX = dPadButtonSizeRel*width + local dPadButtonSizeY = dPadButtonSizeX + local dPadTopLeftX=0 + local dPadTopLeftY=height-3*dPadButtonSizeY + local i=0 + local j=0 + --for i=0,2,1 do + -- for j=0,2,1 do + -- love.graphics.rectangle("line",dPadTopLeftX+i*dPadButtonSizeX,dPadTopLeftY+j*dPadButtonSizeY,dPadButtonSizeX,dPadButtonSizeY) + -- end + --end + for i=0,3,1 do + -- horizontal lines + love.graphics.line(dPadTopLeftX+1,dPadTopLeftY+i*dPadButtonSizeY,dPadTopLeftX+3*dPadButtonSizeX-1,dPadTopLeftY+i*dPadButtonSizeY) + -- vertical lines + love.graphics.line(dPadTopLeftX+i*dPadButtonSizeX,dPadTopLeftY+1,dPadTopLeftX+i*dPadButtonSizeX,dPadTopLeftY+3*dPadButtonSizeY-1) + end + -- virtual firebutton rectangle + local fireButtonSizeX = fireButtonSizeRel*width + local fireButtonSizeY = fireButtonSizeX + local fireButtonTopLeftX=width-fireButtonSizeX + local fireButtonTopLeftY=height-fireButtonSizeY + love.graphics.rectangle("line",fireButtonTopLeftX+i*fireButtonSizeX,fireButtonTopLeftY+j*dPadButtonSizeY,fireButtonSizeX,fireButtonSizeY) + end --[[ if gameWasPaused==true then love.graphics.print("Starting in: "..(timeToWaitAfterPause-timeSinceUnpausing).." s", centerX-50, centerY-5) diff --git a/src/Input.lua b/src/Input.lua index 7cf6c86..72b5df7 100755 --- a/src/Input.lua +++ b/src/Input.lua @@ -13,7 +13,7 @@ function getInputPlayer(playerNumber) local width = love.graphics.getWidth() local height = love.graphics.getHeight() -- relative (square) button size - local dPadButtonSizeX = 0.1*width + local dPadButtonSizeX = dPadButtonSizeRel*width local dPadButtonSizeY = dPadButtonSizeX -- top left coordinate of virtual gamepad local dPadTopLeftX=0 @@ -25,7 +25,7 @@ function getInputPlayer(playerNumber) xInput = i-2 yInput = j-2 end - local fireButtonSizeX = 0.3*width + local fireButtonSizeX = fireButtonSizeRel*width local fireButtonSizeY = fireButtonSizeX -- large virtual firebutton on the bottom right local fireButtonTopLeftX=width-fireButtonSizeX diff --git a/src/Load.lua b/src/Load.lua index 133314e..2242a27 100755 --- a/src/Load.lua +++ b/src/Load.lua @@ -17,6 +17,10 @@ function love.load() statusBarHeight=50 touching = false + -- gamepad touch button sizes as fraction of displaywidth + dPadButtonSizeRel = 0.1 + fireButtonSizeRel = 0.3 + defaultAudioSourceZPos = 0.5 -- controls the amount of stereo panning, 0 is absolute only left/right, 1 is barely noticeable panning