@@ -1101,7 +1194,10 @@ function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
end
end
function love.keypressed(key)
lastSentKey = key
if not isAndroid then
lastSentKey = key
end
if gameState == "chooseIP" then
if key == "backspace" then
-- get the byte offset to the last UTF-8 character in the string.
@@ -1165,8 +1261,10 @@ function love.keypressed(key)
end
end
if key == "escape" then
TEXT = "Escape Key"
love.event.quit()
if not isAndroid then
TEXT = "Escape Key"
love.event.quit()
end
elseif key == "enter" or key == "return" then
if gameState == "start" then
resettinggenius()
@@ -1197,7 +1295,7 @@ function love.keypressed(key)
else
gameState = "menu"
globalState = "menu"
if (love.math.random(0, 10) == 1) then
if (love.math.random(0, 20) == 1) then
TEXT = "Nuclear Ching Chong"
else
TEXT = "Nuclear Pong"
@@ -1212,7 +1310,7 @@ end
function love.keyreleased(key)
currentKey = " "
if lastSentKey == key then
if lastSentKey == key and not isAndroid then
lastSentKey = "g"
end
end
@@ -1546,9 +1644,13 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE
if (gameState == "1serve") then
updateTEXT = ""
if (gameMode ~= "practice") then
TEXT = "PLAYER 1, serve!(q)"
if isAndroid then
TEXT = "PLAYER 1, serve!(double-click)"
else
TEXT = "PLAYER 1, serve!(q)"
end
end
if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q")) then
if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q") or doubleclick1) then
TEXT = "Lets Begin!"
ball_DIR = 1
if maxBalls == 1 then
@@ -1563,7 +1665,13 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE
end
end
if (gameState == "2serve") then
TEXT = "PLAYER 2, serve!(p)"
if (gameMode ~= "practice") then
if isAndroid then
TEXT = "PLAYER 2, serve!(double-click)"
else
TEXT = "PLAYER 2, serve!(p)"
end
end
if (AGAINST_AI == 1) then
TEXT = ""
ball_DIR = -1
@@ -1578,7 +1686,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE
gameState = "play"
end
if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")) or doubleclick2)and AGAINST_AI == 0) then
TEXT = "Lets Begin"
ball_DIR = -1
if maxBalls == 1 then
@@ -1941,4 +2049,113 @@ function selfHost(dt)
gts = 0
end
end
end
end
local lastclick = 0
local clickInterval = 0.4
function love.touchpressed( id, x, y, dx, dy, pressure )
if (love.keyboard.isDown(p1control.up) or sectortouched(2)) then
player1.dy = (paddle_SPEED + p1bonus) * -1
elseif (love.keyboard.isDown(p1control.down)) then
elseif (love.keyboard.isDown(p1control.down) or sectortouched(3)) then
player1.dy = paddle_SPEED + p1bonus
else
player1.dy = 0
end
if (AGAINST_AI == 0) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) ) then
if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1))) ) then
player2.dy = (paddle_SPEED + p2bonus) * -1
elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down))) then
elseif ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.down) or sectortouched(4)))) then
player2.dy = paddle_SPEED + p2bonus
elseif (globalState ~= "nettest") then
player2.dy = 0
@@ -108,7 +108,7 @@ function basegame(dt)
ball[i].dx = -ball[i].dx
ball[i].x = player1.x + 30
if (love.keyboard.isDown(p1control.up)) then
if (love.keyboard.isDown(p1control.up) or sectortouched(2)) then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = -1
@@ -121,7 +121,7 @@ function basegame(dt)
elseif select == 5 then
ball[i].dy = -2
end
elseif love.keyboard.isDown(p1control.down) then
elseif love.keyboard.isDown(p1control.down) or sectortouched(3) then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = 1
@@ -239,7 +239,7 @@ function basegame(dt)
ball[i].dx = -ball[i].dx
ball[i].x = player2.x - 30
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1)) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = -1
@@ -252,7 +252,7 @@ function basegame(dt)
elseif select == 5 then
ball[i].dy = -2
end
elseif (globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
elseif (globalState ~= "nettest" and (love.keyboard.isDown(p2control.down)or sectortouched(4))) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = 1
@@ -463,20 +463,20 @@ end
function powerAvailability()
if (player1nukescore >= 20 and player1nukescore < 140) then
potentialstrike1 = 1
if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
if (((globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
player1striken = 1
player1reverbav = 0
end
end
if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and (maxBalls > 1 or (ball[1].dx < 0 and ball[1].x < VIRTUAL_WIDTH/2))then
player1reverbav = 1
if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.counter) or hold1 == true))) then
powerControl(1, "special")
end
end
if (player1nukescore >= 200) then
potentialnuke1 = 1
if ((globalState == "clienttest" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
if ((globalState == "clienttest" and (lastSentKeyP1 == p1control.super or doubleclick1 == true))or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
sounds["nuke"]:play()
if areanuclear == 1 then
maxspeed = maxspeed + 50
@@ -505,7 +505,7 @@ function powerAvailability()
if (player2nukescore >= 20 and player2nukescore <= 140) then
potentialstrike2 = 1
if (AGAINST_AI == 0) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super ) then
if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super ) then
player2striken = 1
player2reverbav = 0
end
@@ -513,7 +513,7 @@ function powerAvailability()
end
if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and (maxBalls > 1 or (ball[1].dx > 0 and ball[1].x < VIRTUAL_WIDTH/2)) then
player2reverbav = 1
if (globalState ~= "nettest" and love.keyboard.isDown(p2control.counter)) or lastSentKeyClient == p2control.counter then
if (globalState ~= "nettest" and (love.keyboard.isDown(p2control.counter) or hold2)) or lastSentKeyClient == p2control.counter then
sounds["time"]:play()
player2reverbav = false
timeIsSlow2 = true
@@ -526,7 +526,7 @@ function powerAvailability()
end
if (player2nukescore >= 200) then
potentialnuke2 = 1
if (((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
if (((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
love.graphics.printf("The green zones are for moving up and down, double tap the red zone for special attack or to start the serve.", 10, 150, VIRTUAL_WIDTH, "center")
love.graphics.printf("Swipe from red to green for stopping time", 10, 450, VIRTUAL_WIDTH, "center")