Browse Source

Added android support

tags/crossplatform
Madiwka4 4 years ago
parent
commit
6f00221caa
6 changed files with 336 additions and 56 deletions
  1. +249
    -32
      main.lua
  2. +10
    -2
      mainMenu.lua
  3. +5
    -0
      src/androidCs
  4. +65
    -21
      src/baseGame.lua
  5. +2
    -1
      src/constantvars.lua
  6. +5
    -0
      src/pcCs

+ 249
- 32
main.lua View File

@@ -9,8 +9,15 @@ vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) {
return pixel * color;
}
]]

--ANDROID EXLUSIVE VARIABLES
touches = {}
doubleclick1 = false
doubleclick2 = false
hold1 = false
hold2 = false
debug = true
androidButtons = {}
showTouchControls = false
--GLOBAL VARIABLES
frameratecap = 1/60
realtimer = 0
@@ -87,6 +94,15 @@ p1control = {up = "a", down = "z", super = "s", counter = "x"}
p2control = {up = ";", down = ".", super = "l", counter = ","}
synctext = "Independent"
synctype = 0
function newTouch(id, x, y)
return {
id = id,
x = x,
y = y,
originalX = x,
originalY = y
}
end
function newButton(text, fn)
return {
text = text,
@@ -163,6 +179,53 @@ function love.load()

light = 0
image = love.graphics.newImage("Madi.png")
table.insert(
androidButtons,
newButton(
"H",
function()
if gameState == "start" then
resettinggenius()
gameState = "menu"
globalState = "menu"
hardmanager()
elseif (gameState == "done") then
if (player1score > player2score) then
gameState = "2serve"
potentialnuke1 = 0
potentialnuke2 = 0
striken = 0
if (nuckemodactive == 0) then
areanuclear = 0
nuclearanimation = 3
end
potentialstrike1 = 0
potentialstrike2 = 0
player1nukescore = 0
player2nukescore = 0
else
gameState = "1serve"
resettinggenius()
for i = 1, maxBalls do
ball[i]:reset(i, 1)
end
end
else
gameState = "menu"
globalState = "menu"
if (love.math.random(0, 10) == 1) then
TEXT = "Nuclear Ching Chong"
else
TEXT = "Nuclear Pong"
end
resettinggenius()
for i = 1, maxBalls do
ball[i]:reset(i)
end
end
end
)
)
table.insert(
editorpicks,
newButton(
@@ -207,6 +270,9 @@ function love.load()
"Online",
function()
MAP_TYPE = 0
if isAndroid then
love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3)
end
gameState = "chooseIP"
end
)
@@ -244,16 +310,33 @@ function love.load()
end
)
)
table.insert(
buttons,
newButton(
"Settings",
function()
AGAINST_AI = 0
gameState = "windowsettings"
end
if not isAndroid then
table.insert(
buttons,
newButton(
"Settings",
function()
AGAINST_AI = 0
gameState = "windowsettings"
end
)
)
)
else
table.insert(
buttons,
newButton(
"Show Controls",
function()
if showTouchControls then
showTouchControls = false
else
showTouchControls = true
end
gameState = "touchcontrols"
end
)
)
end
table.insert(
buttons,
newButton(
@@ -685,6 +768,11 @@ function love.load()
ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y)
if isAndroid then
myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
DIFFERENCE_X = myscreen.c
DIFFERENCE_Y = myscreen.d
end
mymenu = mainMenu()

ballSpeed = 200
@@ -802,6 +890,7 @@ function nettest(dt)
'|' .. tostring(ball[1].dx) ..
'|' .. tostring(ballSpeed) ..
'|' .. tostring(paddle_SPEED) ..
'|' .. tostring(player1striken) ..
"|HOST")
ts = 0
end
@@ -819,11 +908,11 @@ function nettest(dt)
print("ReceivedINFO: " .. data)
confirmation = "N"
local p = split(data, '|')
if p[15] then
if tonumber(p[16]) > 90 then
if p[16] then
if tonumber(p[17]) > 90 then
confirmation = "L"
end
if p[15] ~= "CLIENT" then
if p[16] ~= "CLIENT" then
confirmation = "U"
end
elseif p[1] == "RESPONSE" then
@@ -837,7 +926,7 @@ function nettest(dt)
confirmation = "U"
end

if p[15] then
if p[16] then
if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then
ball[1].disabled = false
print("illegal disabling")
@@ -858,7 +947,8 @@ function nettest(dt)
gameState,
ball[1].dx,
ballSpeed,
paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14])
paddle_SPEED,
player2striken = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15])
print("ACCEPTED")
else
print("DECLINED")
@@ -878,11 +968,12 @@ function nettest(dt)
gameState,
ball[1].dx,
ballSpeed,
paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14])
paddle_SPEED, player2striken = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15])
print("ACCEPTED")
else
print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx)
lastSentKeyClient = p[1]
player2striken = tonumber(p[15])
player2.y = tonumber(p[4])
end
end
@@ -925,7 +1016,8 @@ function clienttest(dt)
'|' .. gameState ..
'|' .. tostring(ball[1].dx) ..
'|' .. tostring(ballSpeed) ..
'|' .. tostring(paddle_SPEED) ..
'|' .. tostring(paddle_SPEED) ..
'|' .. tostring(player2striken) ..
"|CLIENT")
ts = 0
end
@@ -943,28 +1035,29 @@ function clienttest(dt)
print("SENT TO SERVER:" .. lastSentKey)
confirmation = "N"
local p = split(data, '|')
if p[15] then
if p[15] ~= "HOST" then
if p[16] then
if p[16] ~= "HOST" then
confirmation = "U"
end
if tonumber(p[16]) > 90 then
if tonumber(p[17]) > 90 then
confirmation = "L"
end
for i = 1, maxBalls do
local die = tonumber(p[2])
if (ball[i].x <= VIRTUAL_WIDTH/2) then
if tonumber(p[9]) <= VIRTUAL_WIDTH/2 then
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14])
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15])
print("ACCEPTED")
else
print("DECLINED")
end
else
if tonumber(p[9]) <= VIRTUAL_WIDTH/2 then
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14])
lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15])
print("REROUTED")
else lastSentKeyClient = p[1]
player1.y = tonumber(p[4])
player1striken = tonumber(p[15])
print("ENFORCED")
end
end
@@ -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 isAndroid then
local existsingID = touchExists(id)
if existsingID ~= -1 then
touches[existsingID].x = x * DIFFERENCE_X
touches[existsingID].y = y * DIFFERENCE_Y
else
table.insert(touches, newTouch(id, x*DIFFERENCE_X, y*DIFFERENCE_Y))
local time = love.timer.getTime()
if x * DIFFERENCE_X < VIRTUAL_WIDTH/2 then
if time <= lastclick + clickInterval and x*DIFFERENCE_X > 50 then
doubleclick1 = true
if gameState == "1serve" then
lastSentKey = "q"
else
lastSentKey = p1control.super
end
else
doubleclick1 = false
lastclick = time
end
else
if time <= lastclick + clickInterval and x*DIFFERENCE_X > VIRTUAL_WIDTH-50 then
doubleclick2 = true
if gameState == "2serve" then
lastSentKey = "p"
else
lastSentKey = p2control.super
end
else
doubleclick2 = false
lastclick = time
end
end
end
end
end
function love.touchreleased( id, x, y, dx, dy, pressure )
if isAndroid then
if gameState == "start" then
resettinggenius()
gameState = "menu"
globalState = "menu"
hardmanager()

end
local existsingID = touchExists(id)
if existsingID ~= -1 then
table.remove(touches, existsingID)
end
end
end
function love.touchmoved( id, x, y, dx, dy, pressure )
if isAndroid then
local existsingID = touchExists(id)
if existsingID ~= -1 then
touches[existsingID].x = x * DIFFERENCE_X
touches[existsingID].y = y * DIFFERENCE_Y
if touches[existsingID].originalX - touches[existsingID].x > 200 and
touches[existsingID].originalX < VIRTUAL_WIDTH/2 then
hold1 = true
lastSentKey = p1control.counter
else
hold1 = false
end
if touches[existsingID].x - touches[existsingID].originalX > 200 and
touches[existsingID].originalX > VIRTUAL_WIDTH/2 then
hold2 = true
lastSentKey = p2control.counter
else
hold2 = false
end
end
end
end
function touchExists(ID)
for i, touch in ipairs(touches) do
if touch.id == ID then
return i
end
end
return -1
end
function table.empty (self)
for _, _ in pairs(self) do
return false
end
return true
end
function sectortouched(sector)
for i, touch in ipairs(touches) do
if sector == 1 and touch.x > VIRTUAL_WIDTH-60 and touch.y < VIRTUAL_HEIGHT/2 then
lastSentKey = p2control.up
return true
elseif sector == 2 and touch.x < 60 and touch.y < VIRTUAL_HEIGHT/2 then
lastSentKey = p1control.up
return true
elseif sector == 3 and touch.x < 60 and touch.y > VIRTUAL_HEIGHT/2 then
lastSentKey = p1control.down
return true
elseif sector == 4 and touch.x > VIRTUAL_WIDTH-60 and touch.y > VIRTUAL_HEIGHT/2 then
lastSentKey = p2control.down
return true
end
end
return false
end

+ 10
- 2
mainMenu.lua View File

@@ -52,9 +52,17 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
elseif location == 'control' then
locationx = (VIRTUAL_WIDTH * 0.2)
locationy = (VIRTUAL_HEIGHT* 0.5)
elseif location == "android" then
locationx = (VIRTUAL_WIDTH * 0.5)
locationy = (10)
end
local ev_button_width = VIRTUAL_WIDTH * (1/3)
local ev_BUTTON_HEIGHT = 50
local ev_button_width = VIRTUAL_WIDTH * (1/3)
local ev_BUTTON_HEIGHT = 50
if location == "android" then
ev_button_width = 30
ev_BUTTON_HEIGHT = 30
end
local margin = 16
local hot = false
local cursor_y = 0


+ 5
- 0
src/androidCs View File

@@ -0,0 +1,5 @@
VIRTUAL_WIDTH = 1280
VIRTUAL_HEIGHT = 720
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
isAndroid = true

+ 65
- 21
src/baseGame.lua View File

@@ -21,17 +21,17 @@ function basegame(dt)
if (AGAINST_AI == 1) then
AI(player2, maxBalls, AI_LEVEL)
end
if (love.keyboard.isDown(p1control.up)) then
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
sounds["nuke"]:play()
if areanuclear == 1 then
maxspeed = maxspeed + 50
@@ -667,6 +667,11 @@ function menuDraw()
love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
end
end
if gameState == "touchcontrols" then
love.graphics.setFont(smallfont)
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")
end
if gameState == "windowsettings" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
love.keyboard.mouseisReleased = false
@@ -689,6 +694,17 @@ function menuDraw()
end
if gameState == "chooseIP" then
IPselect = {}
if isAndroid then
table.insert(
IPselect,
newButton(
IPnew,
function()
love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3)
end
)
)
end
table.insert(
IPselect,
newButton(
@@ -744,7 +760,10 @@ function menuDraw()
love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
end
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
love.keyboard.mouseisReleased = false
if not isAndroid then
love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
end
love.keyboard.mouseisReleased = false
end
if gameState == "menu" then
@@ -768,7 +787,11 @@ function menuDraw()
love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
love.graphics.rotate(rotation)
love.graphics.setFont(smallfont)
love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
if isAndroid then
love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
else
love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
end
love.graphics.setColor(255, 255, 255, 255)
love.graphics.pop()
end
@@ -791,10 +814,14 @@ function baseDraw()
if gameState ~= 'animation' then
--print("Drawing notanimtaion")
love.graphics.setFont(scorefont)
if isAndroid then
androidDraw()
end
menuDraw()
end
end
if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then

love.graphics.setFont(smallfont)
if gameState == 'nuclearExplosion' then
nuclearDraw()
@@ -803,12 +830,29 @@ function baseDraw()
print("Drawing normally")
normalDraw()
end

if isAndroid then
androidDraw()
love.keyboard.mouseisReleased = false
end
end


end

function androidDraw()
--HOME BUTTON HERE
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, androidButtons, sounds, "android")
if showTouchControls then
love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
love.graphics.rectangle("fill", 0, 0, 50, VIRTUAL_HEIGHT)
love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
love.graphics.rectangle("fill", VIRTUAL_WIDTH-50, 0, 50, VIRTUAL_HEIGHT)
love.graphics.setColor(255/255, 15/255, 15/255, 0.5)
love.graphics.rectangle("fill", 50, 0, VIRTUAL_WIDTH/2-50, VIRTUAL_HEIGHT)
love.graphics.rectangle("fill", VIRTUAL_WIDTH/2, 0, VIRTUAL_WIDTH/2-50, VIRTUAL_HEIGHT)
love.graphics.setColor(0, 0, 0, 0.5)
love.graphics.rectangle("fill", VIRTUAL_WIDTH/2-5, 0, 10, VIRTUAL_HEIGHT)
end
end
function renderEditor()
if not blockinput then
love.graphics.setColor(1, 0, 0, 1)
@@ -1048,9 +1092,9 @@ function clientsBaseGame(dt)
player1.dy = 0
-- print("stopping player")
end
if ((love.keyboard.isDown(p2control.up))) then
if ((love.keyboard.isDown(p2control.up) or sectortouched(1))) then
player2.dy = (paddle_SPEED + p2bonus) * -1
elseif ((love.keyboard.isDown(p2control.down))) then
elseif ((love.keyboard.isDown(p2control.down)) or sectortouched(4)) then
player2.dy = paddle_SPEED + p2bonus
else
player2.dy = 0
@@ -1205,7 +1249,7 @@ function clientsBaseGame(dt)
player2nukescore = player2nukescore + 10
ball[i].dx = -ball[i].dx
ball[i].x = player2.x - 30
if ((love.keyboard.isDown(p2control.up))) then
if ((love.keyboard.isDown(p2control.up)) or sectortouched(1)) then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = -1
@@ -1218,7 +1262,7 @@ function clientsBaseGame(dt)
elseif select == 5 then
ball[i].dy = -2
end
elseif (love.keyboard.isDown(p2control.down))then
elseif (love.keyboard.isDown(p2control.down) or sectortouched(4))then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = 1


+ 2
- 1
src/constantvars.lua View File

@@ -1,4 +1,5 @@
VIRTUAL_WIDTH = 1280
VIRTUAL_HEIGHT = 720
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
WINDOW_HEIGHT = 720
isAndroid = true

+ 5
- 0
src/pcCs View File

@@ -0,0 +1,5 @@
VIRTUAL_WIDTH = 1280
VIRTUAL_HEIGHT = 720
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
isAndroid = false

Loading…
Cancel
Save