Browse Source

0.7.9 update

tags/gentletouch
Madiwka3 4 years ago
parent
commit
4ff0eb9cc6
8 changed files with 270 additions and 90 deletions
  1. +6
    -0
      animator.lua
  2. +8
    -2
      fullScreener.lua
  3. +186
    -59
      main.lua
  4. +10
    -2
      mainMenu.lua
  5. +4
    -4
      music.lua
  6. +3
    -2
      src/AI.lua
  7. +52
    -21
      src/baseGame.lua
  8. +1
    -0
      src/constantvars.lua

+ 6
- 0
animator.lua View File

@@ -36,6 +36,12 @@ function staticanimatorcounter(dt)
explosionRange = 0
end
end
if gameState == "done" then
if explosionRange < 40 then
nuclearanimation = nuclearanimation - dt
explosionRange = explosionRange + dt*24
end
end
if (player1anim) then
--print("Effect range: " .. effectRange[0])
effectRange[0] = effectRange[0] + dt*24


+ 8
- 2
fullScreener.lua View File

@@ -1,9 +1,11 @@
fullScreener = Class{}
function fullScreener:init(a,b,c,d)
function fullScreener:init(a,b,c,d,e,f)
self.a = a
self.b = b
self.c = c
self.d = d
self.d = d
self.e = e
self.f = f
end
function fullScreener:toggle(vh, vw)
self.a = self.a + 1
@@ -14,6 +16,8 @@ function fullScreener:toggle(vh, vw)
if (self.b == 1) then
self.c = 1
self.d = 1
self.e = 0
self.f = 0
simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT,{fullscreen = false})
self.b = 0
end
@@ -26,6 +30,8 @@ function fullScreener:toggle(vh, vw)
local newHeight = love.graphics.getHeight()
self.c = VIRTUAL_WIDTH / newWidth
self.d = VIRTUAL_HEIGHT / newHeight
self.e = math.fmod(newWidth * self.d, VIRTUAL_WIDTH) / 2
self.f = math.fmod(newHeight * self.d, VIRTUAL_HEIGHT) / 2
self.b = 1
end


+ 186
- 59
main.lua View File

@@ -15,8 +15,11 @@ doubleclick1 = false
doubleclick2 = false
hold1 = false
hold2 = false
debug = true
debug = false
paused = false
androidButtons = {}
pauseButtons = {}
doneButtons = {}
showTouchControls = false
--GLOBAL VARIABLES
frameratecap = 1/60
@@ -72,6 +75,8 @@ nuckemodactive = 0
maxspeed = 700
DIFFERENCE_X = 1
DIFFERENCE_Y = 1
OFFSET_X = 0
OFFSET_Y = 0
paddle_SPEED = 200
textamount = 15
AI_STRIKEMOD = 1000
@@ -185,50 +190,17 @@ function love.load()
newButton(
"H",
function()
if gameState == "start" then
if globalState == "base" and gameState ~= "done" then
paused = true
else
resettinggenius()
paused = false
gameState = "menu"
ball[1].dx = 1
ball_DIR = 1
ball[1].dy = 1
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"
ball[1].dx = 1
ball[1].dy = 1
ball_DIR = 1
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
)
@@ -244,6 +216,103 @@ function love.load()
end
)
)
table.insert(
pauseButtons,
newButton(
"Resume",
function()
paused = false
TEXT = "Let's Continue"
end
)
)
table.insert(
doneButtons,
newButton(
"Freeplay",
function()
if player1score > player2score then
gameState = "2serve"
else
gameState = "1serve"
end
potentialnuke1 = 0
potentialnuke2 = 0
striken = 0
if (nuckemodactive == 0) then
areanuclear = 0
nuclearanimation = 3
end
potentialstrike1 = 0
potentialstrike2 = 0
player1nukescore = 0
player2nukescore = 0
end
)
)
table.insert(
doneButtons,
newButton(
"Menu",
function()
resettinggenius()
TEXT = "Nuclear Pong"
paused = false
gameState = "menu"
ball[1].dx = 1
ball_DIR = 1
ball[1].dy = 1
globalState = "menu"
hardmanager()
end
)
)
if not isAndroid then
table.insert(
pauseButtons,
newButton(
"Toggle Fullscreen",
function()
myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
DIFFERENCE_X = myscreen.c
DIFFERENCE_Y = myscreen.d
OFFSET_X = myscreen.e
OFFSET_Y = myscreen.f
end
)
)
end
table.insert(
pauseButtons,
newButton(
"Toggle Music",
function()
if mute then
musicController("mute", 0)
else
musicController("mute", 1)
end
end
)
)
table.insert(
pauseButtons,
newButton(
"Menu",
function()
resettinggenius()
paused = false
TEXT = "Nuclear Pong"
gameState = "menu"
ball[1].dx = 1
ball_DIR = 1
ball[1].dy = 1
globalState = "menu"
hardmanager()
end
)
)

table.insert(
editorpicks,
newButton(
@@ -267,6 +336,7 @@ function love.load()
newButton(
"Singleplayer",
function()
ptw = 10
gameState = "gameMode"
end
)
@@ -399,19 +469,21 @@ function love.load()
-- )
--)
table.insert(
buttons,
settings,
newButton(
"Toggle Fullscreen",
function()
myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
DIFFERENCE_X = myscreen.c
DIFFERENCE_Y = myscreen.d
OFFSET_X = myscreen.e
OFFSET_Y = myscreen.f
end
)
)
if isAndroid then
table.insert(
settings,
buttons,
newButton(
"Toggle Music",
function()
@@ -802,11 +874,13 @@ function love.load()
ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
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)
myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y)
if isAndroid then
myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
DIFFERENCE_X = myscreen.c
DIFFERENCE_Y = myscreen.d
OFFSET_X = myscreen.e
OFFSET_Y = myscreen.f
end
mymenu = mainMenu()

@@ -851,9 +925,9 @@ function love.update(dt)
end
if debug then
displayFPS()
print(player2.y .. " " .. player2.goal .. " " .. player2.dy .. " " .. AI_SPEED .. " " .. paddle_SPEED)
end
if globalState == "base" then
print(player2.y .. " " .. player2.goal .. " " .. player2.dy .. " " .. AI_SPEED .. " " .. paddle_SPEED .. " " .. lastSentKeyClient)
end
if globalState == "base" and not paused then
basegame(dt)
end
@@ -867,6 +941,7 @@ function love.update(dt)
musicController('norm', 1)
end
if globalState == "nettest" then
--print("Confcode: " .. confirmation)
if confirmation == "N" then
@@ -894,7 +969,6 @@ function love.update(dt)
end
clienttest(dt)
end

end
serverinit = false
@@ -1319,9 +1393,15 @@ function love.keypressed(key)
end
end
if key == "escape" then
if not isAndroid then
TEXT = "Escape Key"
love.event.quit()
if not isAndroid and globalState == "base" and gameState ~= "done" then
if paused then
paused = false
TEXT = "Let's Continue"
else
paused = true
TEXT = "PAUSED"
end
end
elseif key == "enter" or key == "return" then
if gameState == "start" then
@@ -1497,6 +1577,8 @@ function gameModeChanger()
local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
local color = {255, 255, 255, 255}
local mx, my = love.mouse.getPosition()
mx = mx
my = my
mx = mx * DIFFERENCE_X
my = my * DIFFERENCE_Y
hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
@@ -1538,6 +1620,8 @@ function gameModeChanger()
end
local color = {255, 255, 255, 255}
local mx, my = love.mouse.getPosition()
mx = mx
my = my
mx = mx * DIFFERENCE_X
my = my * DIFFERENCE_Y
hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
@@ -1655,6 +1739,18 @@ function love.draw(dt)
androidDraw()
love.keyboard.mouseisReleased = false
end
if debug then
if touches then
for i, touch in ipairs(touches) do
love.graphics.printf(touch.x, 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
end
if doubleclick1 then
TEXT = "DOUBLECLICK1"
elseif doubleclick2 then TEXT = "DOUBLECLICK2"
else TEXT = "NO"
end
end
end
simpleScale.unSet()
end

@@ -1787,6 +1883,8 @@ function resolutionChanger()
if (isFullscreen == 1) then
DIFFERENCE_X = 1
DIFFERENCE_Y = 1
OFFSET_X = 0
OFFSET_Y = 0
simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
isFullscreen = 0
end
@@ -1798,6 +1896,8 @@ function resolutionChanger()
local newHeight = love.graphics.getHeight()
DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
OFFSET_X = math.fmod(newWidth, VIRTUAL_WIDTH) / 2
OFFSET_Y = math.fmod(newHeight, VIRTUAL_HEIGHT) / 2
isFullscreen = 1
end
end
@@ -1848,7 +1948,7 @@ function love.mousereleased(x, y, button)
love.keyboard.mouseisReleased = true
if (gameState == "editor") then
if (#walls < 1000 and button == 1 and blockinput ~= true) then
table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
table.insert(walls, newWall((x ) * DIFFERENCE_Y , (y ) * DIFFERENCE_Y , 10, wall1width))
end
end
end
@@ -2135,16 +2235,21 @@ end
local lastclick = 0
local clickInterval = 0.4
function love.touchpressed( id, x, y, dx, dy, pressure )
if isAndroid then
if isAndroid then
if x < love.graphics.getWidth()-OFFSET_X/2 then
actualX = (x - OFFSET_X/2) * DIFFERENCE_Y
else
actualX = 1380
end
local existsingID = touchExists(id)
if existsingID ~= -1 then
touches[existsingID].x = x * DIFFERENCE_X
touches[existsingID].y = y * DIFFERENCE_Y
touches[existsingID].x = actualX
touches[existsingID].y = (y) * DIFFERENCE_Y
else
table.insert(touches, newTouch(id, x*DIFFERENCE_X, y*DIFFERENCE_Y))
table.insert(touches, newTouch(id, actualX , (y) * DIFFERENCE_Y))
local time = love.timer.getTime()
if x * DIFFERENCE_X < VIRTUAL_WIDTH/2 then
if time <= lastclick + clickInterval and x*DIFFERENCE_X > 100 then
if actualX < VIRTUAL_WIDTH/2 then
if time <= lastclick + clickInterval and actualX> 100 then
doubleclick1 = true
if gameState == "1serve" then
lastSentKey = "q"
@@ -2155,8 +2260,9 @@ function love.touchpressed( id, x, y, dx, dy, pressure )
doubleclick1 = false
lastclick = time
end

else
if time <= lastclick + clickInterval and x*DIFFERENCE_X < VIRTUAL_WIDTH-100 then
if time <= lastclick + clickInterval and actualX < VIRTUAL_WIDTH-100 then
doubleclick2 = true
if gameState == "2serve" then
lastSentKey = "p"
@@ -2191,10 +2297,15 @@ function love.touchreleased( id, x, y, dx, dy, pressure )
end
function love.touchmoved( id, x, y, dx, dy, pressure )
if isAndroid then
if x < love.graphics.getWidth()-OFFSET_X/2 then
actualX = (x - OFFSET_X/2) * DIFFERENCE_Y
else
actualX = 1380
end
local existsingID = touchExists(id)
if existsingID ~= -1 then
touches[existsingID].x = x * DIFFERENCE_X
touches[existsingID].y = y * DIFFERENCE_Y
touches[existsingID].x = actualX
touches[existsingID].y = (y ) * DIFFERENCE_Y
if touches[existsingID].originalX - touches[existsingID].x > 200 and
touches[existsingID].originalX < VIRTUAL_WIDTH/2 then
hold1 = true
@@ -2229,7 +2340,22 @@ function table.empty (self)
end
function sectortouched(sector)
for i, touch in ipairs(touches) do
if touch.x > VIRTUAL_WIDTH-100 and touch.y < player2.y then
if (AGAINST_AI == 1) then
if sector == 2 and touch.x < 100 and touch.y < player1.y then
lastSentKey = p1control.up
return true
elseif sector == 2 and touch.x > VIRTUAL_WIDTH/2+10 and touch.y < player1.y then
lastSentKey = p1control.up
return true
elseif sector == 3 and touch.x < 100 and touch.y > player1.y+player1.height*0.9 then
lastSentKey = p1control.down
return true
elseif sector == 3 and touch.x > VIRTUAL_WIDTH/2+10 and touch.y > player1.y+player1.height*0.9 then
lastSentKey = p1control.down
return true
end
else
if sector == 1 and touch.x > VIRTUAL_WIDTH-100 and touch.y < player2.y then
lastSentKey = p2control.up
return true
elseif sector == 2 and touch.x < 100 and touch.y < player1.y then
@@ -2242,6 +2368,7 @@ for i, touch in ipairs(touches) do
lastSentKey = p2control.down
return true
end
end
end
return false
end

+ 10
- 2
mainMenu.lua View File

@@ -15,6 +15,8 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
ev_by = (VIRTUAL_HEIGHT * 0.1) - (total_height * 0.5) + cursor_y
local color = {255, 255, 255, 255}
local mx, my = love.mouse.getPosition()
mx = mx
my = my
mx = mx * DIFFERENCE_X
my = my * DIFFERENCE_Y
hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i
@@ -26,7 +28,7 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
button.now = love.keyboard.mouseWasReleased()
if button.now and not button.last and hot == i then
love.keyboard.mouseisReleased = false
love.graphics.setColor(0,0,0,1)
love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
sounds['wallhit']:play()
@@ -99,6 +101,8 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
color = {1,1,1,1}
end
local mx, my = love.mouse.getPosition()
mx = mx
my = my
local mx = mx * DIFFERENCE_X
local my = my * DIFFERENCE_Y
local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i
@@ -112,6 +116,7 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
button.now = love.mouse.isDown(1)
end
if button.now and hot == i then
love.keyboard.mouseisReleased = false
love.graphics.setColor(0,0,0,1)
love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
sounds['wallhit']:play()
@@ -188,7 +193,7 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
end
end
end
love.keyboard.mouseisReleased = false
end
function mainMenu:addButton(text, fn)
return {
@@ -212,6 +217,8 @@ local bx = (VIRTUAL_WIDTH*0.5) - (button_width * 0.5)
local by = (VIRTUAL_HEIGHT * 0.8) - (total_height * 0.5) + cursor_y
local color = {255, 255, 255, 255}
local mx, my = love.mouse.getPosition()
mx = mx
my = my
mx = mx * DIFFERENCE_X
my = my * DIFFERENCE_Y
hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
@@ -220,6 +227,7 @@ if (hot == i) then
end
button.now = love.keyboard.mouseWasReleased()
if button.now and not button.last and hot == i then
love.keyboard.mouseisReleased = false
love.graphics.setColor(0,0,0,1)
love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
sounds['wallhit']:play()


+ 4
- 4
music.lua View File

@@ -9,7 +9,7 @@ function musicController(orders, toggling)
sounds['gayTheme']:setVolume(0)
sounds['gayTheme2']:setVolume(0)
elseif ((gameState == 'play' or gameState == '1serve' or gameState == '2serve') and player1score <= 7 and player2score <= 7 and areanuclear == 0) then
elseif ((gameState == 'play' or gameState == '1serve' or gameState == '2serve') and player1score <= ptw*0.5 and player2score <= ptw*0.5 and areanuclear == 0) then
sounds['updateMusic']:stop()
sounds['gayTheme2']:stop()
sounds['gayTheme3']:stop()
@@ -17,8 +17,8 @@ function musicController(orders, toggling)
sounds['gayTheme']:setLooping(true)
sounds['gayTheme']:setVolume(0.5)
sounds['gayTheme']:play()
elseif gameState == 'play' and player1score > ptw-2 or player2score > ptw-2 and areanuclear == 0 then
--print(ptw-2)
elseif gameState == 'play' and player1score > ptw*0.8 or player2score > ptw*0.8 and areanuclear == 0 then
--print(ptw*0.8)
sounds['gayTheme']:stop()
sounds['gayTheme3']:stop()
sounds['updateMusic']:stop()
@@ -26,7 +26,7 @@ function musicController(orders, toggling)
sounds['gayTheme2']:setLooping(true)
sounds['gayTheme2']:setVolume(0.5)
sounds['gayTheme2']:play()
elseif gameState == 'play' and player1score > ptw-5 or player2score > ptw-5 and areanuclear == 0 then
elseif gameState == 'play' and player1score > ptw*0.5 or player2score > ptw*0.5 and areanuclear == 0 then
--print(ptw-4)
sounds['gayTheme']:stop()
sounds['gayTheme2']:stop()


+ 3
- 2
src/AI.lua View File

@@ -1,4 +1,5 @@
function AI(target, ballCnt, diff)
print("AI RUNNING")
currentTarget = evaluateClosestBall(target);
--print("CLOSEST TARGET IS " .. currentTarget)
if diff < 1200 then
@@ -130,9 +131,9 @@ function recursiveCalculations(px, ex, ey, edx, edy, ifspecial)
--print("SS")
local emulatedx = ex + distance * edx
local emulatedy = VIRTUAL_HEIGHT-40
print("EMULATED: " .. emulatedx .. " " .. emulatedy)
--print("EMULATED: " .. emulatedx .. " " .. emulatedy)
local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0)
print("GOT EMULATION RESULT AS " .. answer)
--print("GOT EMULATION RESULT AS " .. answer)
--love.window.setTitle(tostring(answer) .. "recursive calc bottom")
return answer
end


+ 52
- 21
src/baseGame.lua View File

@@ -41,7 +41,7 @@ function basegame(dt)
for i = 1, maxBalls do
if rules("p1hit", i) then
if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then
--print("Calling animation")
--print("AREA NUCLEAR?" .. areanuclear)
superanimator("tensehit", 1)
@@ -170,7 +170,7 @@ function basegame(dt)
shakeDuration = 1
if
(areanuclear == 0 and
(striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
(striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)))
then
--print("AREA NUCLEAR?" .. areanuclear)
superanimator("tensehit", 2)
@@ -356,7 +356,7 @@ end
function debugCheck(dt)
if (gameState == "menu") then
updateTEXT = "0.7.8 Chalkboard Update"
updateTEXT = "0.7.9 Chalkboard"
end
dangerChecker()
elapsed = elapsed + dt
@@ -394,7 +394,7 @@ function goalManager()
for i = 1, maxBalls do
ball[i]:reset(i, 2)
end
if (player2score == ptw and gameMode ~= "practice") then
if (player2score+1 >= ptw and gameMode ~= "practice") then
for i = 1, maxBalls do
ball[i]:reset(i)
end
@@ -436,12 +436,12 @@ function goalManager()
AI_SPEED = difficultyl
if (player1score == ptw) then
if (player1score+1 >= ptw) then
ball[i]:reset(i)
sounds["win"]:play()
gameState = "done"
TEXT = "Player 1 Won!"
TEXT = "Player 1 Won"
else
if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then
gameState = "2serve"
@@ -461,10 +461,11 @@ function goalManager()
end

function powerAvailability()
if (player1nukescore >= 20 and player1nukescore < 140) then
if (player1nukescore >= 20 and player1nukescore < 200) then
potentialstrike1 = 1
if (((globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
player1striken = 1
doubleclick1 = false
player1reverbav = 0
end
end
@@ -476,8 +477,9 @@ function powerAvailability()
end
if (player1nukescore >= 200) then
potentialnuke1 = 1
if ((globalState == "clienttest" and (lastSentKeyP1 == p1control.super or doubleclick1 == true))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) or doubleclick1 == true))) then
sounds["nuke"]:play()
doubleclick1 = false
if areanuclear == 1 then
maxspeed = maxspeed + 50
end
@@ -502,12 +504,13 @@ function powerAvailability()
potentialnuke1 = 0
end
end
if (player2nukescore >= 20 and player2nukescore <= 140) then
if (player2nukescore >= 20 and player2nukescore < 200) then
potentialstrike2 = 1
if (AGAINST_AI == 0) then
if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super ) then
player2striken = 1
player2reverbav = 0
doubleclick2 = false
end
end
end
@@ -529,6 +532,7 @@ function powerAvailability()
potentialnuke2 = 1
if (((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
sounds["nuke"]:play()
doubleclick2 = false
if areanuclear == 1 then
maxspeed = maxspeed + 50
end
@@ -591,6 +595,20 @@ function nuclearDraw()
player2:render()
end

function winDraw(who)

love.graphics.setColor(0, 0, 0, 1)
if who == 1 then
love.graphics.circle("fill", player2.x, player2.y, explosionRange * 100, 100)
print("cicrleexplostion at " .. explosionRange)
else
love.graphics.circle("fill", player1.x, player1.y, explosionRange * 100, 100)
end
love.graphics.setColor(1, 1, 1, 1)
love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
end

function normalDraw()
if (areanuclear == 1) then
love.graphics.clear(1, 1, 1, 1)
@@ -724,6 +742,7 @@ function menuDraw()
AGAINST_AI = 0
gameState = "1serve"
ball[1]:reset(1, 1)
player2.dy = 0
end
)
)
@@ -751,6 +770,7 @@ function menuDraw()
AGAINST_AI = 0
gameState = "1serve"
ball[1]:reset(1, 1)
player2.dy = 0
end
)
)
@@ -766,6 +786,7 @@ function menuDraw()
AGAINST_AI = 0
gameState = "1serve"
ball[1]:reset(1, 1)
player2.dy = 0
end
)
)
@@ -837,25 +858,37 @@ function baseDraw()
if gameState == 'nuclearExplosion' then
nuclearDraw()
end

if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
--print("Drawing normally")
normalDraw()
end
if gameState == 'done' and player1score > player2score then
winDraw(1)
elseif gameState == 'done' and player1score < player2score then
winDraw(2)
end
end


if paused then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pauseButtons, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "done" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, doneButtons, sounds, "middle")
love.keyboard.mouseisReleased = false
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.rectangle("fill", 0, 0, 100, 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.rectangle("fill", VIRTUAL_WIDTH-100, 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.rectangle("fill", 100, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
love.graphics.rectangle("fill", VIRTUAL_WIDTH/2, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
love.graphics.setColor(0, 0, 0, 0.5)
love.graphics.rectangle("fill", VIRTUAL_WIDTH/2-5, 0, 10, VIRTUAL_HEIGHT)
end
@@ -1061,14 +1094,14 @@ function rules(query, i)
if gameMode == "reversegame" then
return ball[i]:collides(player1)
elseif gameMode == "normal" then
return ball[i].x < 0 and ball[i].disabled == false
return ball[i].x < -10 and ball[i].disabled == false
end
end
if query == "p2miss" then
if gameMode == "reversegame" then
return ball[i]:collides(player2)
elseif gameMode == "normal" then
return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
return ball[i].x > VIRTUAL_WIDTH and ball[i].disabled == false
end
end
end
@@ -1116,7 +1149,7 @@ function clientsBaseGame(dt)
for i = 1, maxBalls do
if rules("p1hit", i) then
if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then
--print("Calling animation")
superanimator("tensehit", 1)
--print("AREA NUCLEAR?" .. areanuclear)
@@ -1188,7 +1221,7 @@ function clientsBaseGame(dt)
shakeDuration = 1
if
(areanuclear == 0 and
(striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
(striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)))
then
--print("AREA NUCLEAR?" .. areanuclear)
superanimator("tensehit", 2)
@@ -1467,7 +1500,6 @@ function menuDemo(dt)
end
ball[1].x = player2.x-8
ball[1].dx = -ball[1].dx
ball[1].dy = -ball[1].dy
end
if ball[1].x <= player1.x+7 then
sounds["beep"]:setPitch(ballSpeed / 250)
@@ -1502,7 +1534,6 @@ function menuDemo(dt)
end
ball[1].x = player1.x+8
ball[1].dx = -ball[1].dx
ball[1].dy = -ball[1].dy
end
if ball[1].y <= 0 then


+ 1
- 0
src/constantvars.lua View File

@@ -2,3 +2,4 @@ VIRTUAL_WIDTH = 1280
VIRTUAL_HEIGHT = 720
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
isAndroid = true

Loading…
Cancel
Save