| @@ -7,11 +7,11 @@ local diseffectRange = {[0] = 0,[1] = 0} | |||||
| function superanimator(type, param) | function superanimator(type, param) | ||||
| if type == 'tensehit' then | if type == 'tensehit' then | ||||
| if param == 1 then | if param == 1 then | ||||
| print("Animation called!") | |||||
| --print("Animation called!") | |||||
| player1anim = true | player1anim = true | ||||
| end | end | ||||
| if param == 2 then | if param == 2 then | ||||
| print("Animation called!") | |||||
| --print("Animation called!") | |||||
| player2anim = true | player2anim = true | ||||
| end | end | ||||
| end | end | ||||
| @@ -37,14 +37,14 @@ function staticanimatorcounter(dt) | |||||
| end | end | ||||
| end | end | ||||
| if (player1anim) then | if (player1anim) then | ||||
| print("Effect range: " .. effectRange[0]) | |||||
| --print("Effect range: " .. effectRange[0]) | |||||
| effectRange[0] = effectRange[0] + dt*24 | effectRange[0] = effectRange[0] + dt*24 | ||||
| if effectRange[0] > 7500/ballSpeed then | if effectRange[0] > 7500/ballSpeed then | ||||
| player1animend = true | player1animend = true | ||||
| end | end | ||||
| end | end | ||||
| if player1animend then | if player1animend then | ||||
| print("DISEffect range: " .. diseffectRange[0]) | |||||
| --print("DISEffect range: " .. diseffectRange[0]) | |||||
| diseffectRange[0] = diseffectRange[0] + dt*24 | diseffectRange[0] = diseffectRange[0] + dt*24 | ||||
| if diseffectRange[0] > 50 then | if diseffectRange[0] > 50 then | ||||
| effectRange[0] = 0 | effectRange[0] = 0 | ||||
| @@ -54,14 +54,14 @@ function staticanimatorcounter(dt) | |||||
| end | end | ||||
| end | end | ||||
| if (player2anim) then | if (player2anim) then | ||||
| print("Effect range: " .. effectRange[1]) | |||||
| --print("Effect range: " .. effectRange[1]) | |||||
| effectRange[1] = effectRange[1] + dt*24 | effectRange[1] = effectRange[1] + dt*24 | ||||
| if effectRange[1] > 7500/ballSpeed then | if effectRange[1] > 7500/ballSpeed then | ||||
| player2animend = true | player2animend = true | ||||
| end | end | ||||
| end | end | ||||
| if player2animend then | if player2animend then | ||||
| print("DISEffect range: " .. diseffectRange[1]) | |||||
| --print("DISEffect range: " .. diseffectRange[1]) | |||||
| diseffectRange[1] = diseffectRange[1] + dt*24 | diseffectRange[1] = diseffectRange[1] + dt*24 | ||||
| if diseffectRange[1] > 50 then | if diseffectRange[1] > 50 then | ||||
| effectRange[1] = 0 | effectRange[1] = 0 | ||||
| @@ -10,6 +10,7 @@ function eball:init(x, y, width, height) | |||||
| self.dy = math.random(-1, 1) | self.dy = math.random(-1, 1) | ||||
| self.dx = 1 | self.dx = 1 | ||||
| self.disabled = false | self.disabled = false | ||||
| end | end | ||||
| function eball:collides(paddle) | function eball:collides(paddle) | ||||
| @@ -98,9 +99,9 @@ function eball:update(dt) | |||||
| else | else | ||||
| potentialnuke2 = 0 | potentialnuke2 = 0 | ||||
| end | end | ||||
| print("ATTEMP TO UPDATE BALL") | |||||
| --print("ATTEMP TO UPDATE BALL") | |||||
| if self.disabled == false then | if self.disabled == false then | ||||
| print("BALL IS BEING AUTO-UPDATED") | |||||
| --print("BALL IS BEING AUTO-UPDATED" .. ballSpeed .. " " .. self.dx .. " " .. self.dy) | |||||
| self.x = self.x + ballSpeed * self.dx * dt | self.x = self.x + ballSpeed * self.dx * dt | ||||
| self.y = self.y + ballSpeed * self.dy * dt | self.y = self.y + ballSpeed * self.dy * dt | ||||
| end | end | ||||
| @@ -34,6 +34,7 @@ blockinput = false | |||||
| wall1width = 30 | wall1width = 30 | ||||
| nuclearanimation = 3 | nuclearanimation = 3 | ||||
| easternum = 0 | easternum = 0 | ||||
| qq = 0 | |||||
| ball_DIR = 0 | ball_DIR = 0 | ||||
| updaterate = 0.015 | updaterate = 0.015 | ||||
| RED = 255 | RED = 255 | ||||
| @@ -187,6 +188,9 @@ function love.load() | |||||
| if gameState == "start" then | if gameState == "start" then | ||||
| resettinggenius() | resettinggenius() | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball_DIR = 1 | |||||
| ball[1].dy = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| hardmanager() | hardmanager() | ||||
| elseif (gameState == "done") then | elseif (gameState == "done") then | ||||
| @@ -212,6 +216,9 @@ function love.load() | |||||
| end | end | ||||
| else | else | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball[1].dy = 1 | |||||
| ball_DIR = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| if (love.math.random(0, 10) == 1) then | if (love.math.random(0, 10) == 1) then | ||||
| TEXT = "Nuclear Ching Chong" | TEXT = "Nuclear Ching Chong" | ||||
| @@ -648,7 +655,7 @@ function love.load() | |||||
| function() | function() | ||||
| speedSetter("reset") | speedSetter("reset") | ||||
| gameState = "menu" | gameState = "menu" | ||||
| end | end | ||||
| ) | ) | ||||
| ) | ) | ||||
| @@ -809,7 +816,8 @@ function love.update(dt) | |||||
| --print("IMPORTANT!!!!!" .. globalState .. gameState) | --print("IMPORTANT!!!!!" .. globalState .. gameState) | ||||
| staticanimatorcounter(dt) | staticanimatorcounter(dt) | ||||
| musicController('norm', 1) | |||||
| player1.goal = -1 | |||||
| player2.goal = -1 | |||||
| if gameState == "chooseIP" then | if gameState == "chooseIP" then | ||||
| checkCurrentServer(dt) | checkCurrentServer(dt) | ||||
| end | end | ||||
| @@ -818,11 +826,18 @@ function love.update(dt) | |||||
| end | end | ||||
| if globalState == "base" then | if globalState == "base" then | ||||
| basegame(dt) | basegame(dt) | ||||
| end | end | ||||
| if globalState == "menu" then | if globalState == "menu" then | ||||
| debugCheck(dt) | debugCheck(dt) | ||||
| if gameState ~= "animation" then | |||||
| menuDemo(dt) | |||||
| end | |||||
| end | |||||
| if gameState ~= "animation" then | |||||
| musicController('norm', 1) | |||||
| end | end | ||||
| if globalState == "nettest" then | if globalState == "nettest" then | ||||
| --print("Confcode: " .. confirmation) | --print("Confcode: " .. confirmation) | ||||
| if confirmation == "N" then | if confirmation == "N" then | ||||
| @@ -863,11 +878,11 @@ function love.textinput(t) | |||||
| end | end | ||||
| end | end | ||||
| function nettest(dt) | function nettest(dt) | ||||
| print("nettest running") | |||||
| --print("nettest running") | |||||
| if serverinit == false then | if serverinit == false then | ||||
| local socket = require "socket" | local socket = require "socket" | ||||
| local address, port = IP, 12345 | local address, port = IP, 12345 | ||||
| print(address) | |||||
| --print(address) | |||||
| udp = socket.udp() | udp = socket.udp() | ||||
| udp:setpeername(address, port) | udp:setpeername(address, port) | ||||
| udp:settimeout(0) | udp:settimeout(0) | ||||
| @@ -896,6 +911,7 @@ function nettest(dt) | |||||
| '|' .. tostring(ballSpeed) .. | '|' .. tostring(ballSpeed) .. | ||||
| '|' .. tostring(paddle_SPEED) .. | '|' .. tostring(paddle_SPEED) .. | ||||
| '|' .. tostring(player1striken) .. | '|' .. tostring(player1striken) .. | ||||
| '|' .. tostring(areanuclear) .. | |||||
| "|HOST") | "|HOST") | ||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| @@ -906,18 +922,18 @@ function nettest(dt) | |||||
| local datawaspassed = false | local datawaspassed = false | ||||
| repeat | repeat | ||||
| datanumtest = datanumtest + 1 | datanumtest = datanumtest + 1 | ||||
| print("LATENCY: " .. tostring(datanumtest)) | |||||
| --print("LATENCY: " .. tostring(datanumtest)) | |||||
| data = udp:receive() | data = udp:receive() | ||||
| if data then | if data then | ||||
| datawaspassed = true | datawaspassed = true | ||||
| print("ReceivedINFO: " .. data) | |||||
| --print("ReceivedINFO: " .. data) | |||||
| confirmation = "N" | confirmation = "N" | ||||
| local p = split(data, '|') | local p = split(data, '|') | ||||
| if p[16] then | |||||
| if tonumber(p[17]) > 90 then | |||||
| if p[17] then | |||||
| if tonumber(p[18]) > 90 then | |||||
| confirmation = "L" | confirmation = "L" | ||||
| end | end | ||||
| if p[16] ~= "CLIENT" then | |||||
| if p[17] ~= "CLIENT" then | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| elseif p[1] == "RESPONSE" then | elseif p[1] == "RESPONSE" then | ||||
| @@ -931,10 +947,10 @@ function nettest(dt) | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| if p[16] then | |||||
| if p[17] then | |||||
| if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then | if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then | ||||
| ball[1].disabled = false | ball[1].disabled = false | ||||
| print("illegal disabling") | |||||
| --print("illegal disabling") | |||||
| end | end | ||||
| if gameState ~= "1serve" then | if gameState ~= "1serve" then | ||||
| if (ball[1].x > VIRTUAL_WIDTH/2) then | if (ball[1].x > VIRTUAL_WIDTH/2) then | ||||
| @@ -953,10 +969,11 @@ function nettest(dt) | |||||
| ball[1].dx, | ball[1].dx, | ||||
| ballSpeed, | ballSpeed, | ||||
| paddle_SPEED, | 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") | |||||
| player2striken, | |||||
| areanuclear = 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]), tonumber(p[16]) | |||||
| --print("ACCEPTED") | |||||
| else | else | ||||
| print("DECLINED") | |||||
| --print("DECLINED") | |||||
| end | end | ||||
| else | else | ||||
| if tonumber(p[9]) > VIRTUAL_WIDTH/2 then | if tonumber(p[9]) > VIRTUAL_WIDTH/2 then | ||||
| @@ -973,10 +990,11 @@ function nettest(dt) | |||||
| gameState, | gameState, | ||||
| ball[1].dx, | ball[1].dx, | ||||
| ballSpeed, | ballSpeed, | ||||
| 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") | |||||
| paddle_SPEED, player2striken, | |||||
| areanuclear = 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]), tonumber(p[16]) | |||||
| --print("ACCEPTED") | |||||
| else | else | ||||
| print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx) | |||||
| --print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx) | |||||
| lastSentKeyClient = p[1] | lastSentKeyClient = p[1] | ||||
| player2striken = tonumber(p[15]) | player2striken = tonumber(p[15]) | ||||
| player2.y = tonumber(p[4]) | player2.y = tonumber(p[4]) | ||||
| @@ -1028,6 +1046,7 @@ function clienttest(dt) | |||||
| '|' .. tostring(ballSpeed) .. | '|' .. tostring(ballSpeed) .. | ||||
| '|' .. tostring(paddle_SPEED) .. | '|' .. tostring(paddle_SPEED) .. | ||||
| '|' .. tostring(player2striken) .. | '|' .. tostring(player2striken) .. | ||||
| '|' .. tostring(areanuclear) .. | |||||
| "|CLIENT") | "|CLIENT") | ||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| @@ -1036,17 +1055,17 @@ function clienttest(dt) | |||||
| local datawaspassed = false | local datawaspassed = false | ||||
| repeat | repeat | ||||
| datanumtest = datanumtest + 1 | datanumtest = datanumtest + 1 | ||||
| print("LATENCY: " .. tostring(datanumtest)) | |||||
| --print("LATENCY: " .. tostring(datanumtest)) | |||||
| data = udp:receive() | data = udp:receive() | ||||
| if data then | if data then | ||||
| print("RECEIVED DATA: " .. data) | |||||
| --print("RECEIVED DATA: " .. data) | |||||
| datawaspassed = true | datawaspassed = true | ||||
| print("SENT TO SERVER:" .. lastSentKey) | |||||
| --print("SENT TO SERVER:" .. lastSentKey) | |||||
| confirmation = "N" | confirmation = "N" | ||||
| local p = split(data, '|') | local p = split(data, '|') | ||||
| if p[16] then | |||||
| if p[16] ~= "HOST" then | |||||
| if p[17] then | |||||
| if p[18] ~= "HOST" then | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| if tonumber(p[17]) > 90 then | if tonumber(p[17]) > 90 then | ||||
| @@ -1056,19 +1075,19 @@ function clienttest(dt) | |||||
| local die = tonumber(p[2]) | local die = tonumber(p[2]) | ||||
| if (ball[i].x <= VIRTUAL_WIDTH/2) then | if (ball[i].x <= VIRTUAL_WIDTH/2) then | ||||
| if tonumber(p[9]) <= 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, 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") | |||||
| lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken, areanuclear = 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]), tonumber(p[16]) | |||||
| --print("ACCEPTED") | |||||
| else | else | ||||
| print("DECLINED") | |||||
| --print("DECLINED") | |||||
| end | end | ||||
| else | else | ||||
| if tonumber(p[9]) <= 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, 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") | |||||
| lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken, areanuclear = 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]), tonumber(p[16]) | |||||
| --print("REROUTED") | |||||
| else lastSentKeyClient = p[1] | else lastSentKeyClient = p[1] | ||||
| player1.y = tonumber(p[4]) | player1.y = tonumber(p[4]) | ||||
| player1striken = tonumber(p[15]) | player1striken = tonumber(p[15]) | ||||
| print("ENFORCED") | |||||
| --print("ENFORCED") | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| @@ -1076,7 +1095,7 @@ function clienttest(dt) | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| end | end | ||||
| print("GOT: " .. lastSentKeyClient) | |||||
| --print("GOT: " .. lastSentKeyClient) | |||||
| until not data | until not data | ||||
| if not datawaspassed then | if not datawaspassed then | ||||
| datawaspassedtimer = datawaspassedtimer + 1 | datawaspassedtimer = datawaspassedtimer + 1 | ||||
| @@ -1279,6 +1298,8 @@ function love.keypressed(key) | |||||
| if gameState == "start" then | if gameState == "start" then | ||||
| resettinggenius() | resettinggenius() | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball[1].dy = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| hardmanager() | hardmanager() | ||||
| elseif (gameState == "done") then | elseif (gameState == "done") then | ||||
| @@ -1304,6 +1325,8 @@ function love.keypressed(key) | |||||
| end | end | ||||
| else | else | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball[1].dy = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| if (love.math.random(0, 20) == 1) then | if (love.math.random(0, 20) == 1) then | ||||
| TEXT = "Nuclear Ching Chong" | TEXT = "Nuclear Ching Chong" | ||||
| @@ -1599,7 +1622,10 @@ function love.draw(dt) | |||||
| love.graphics.printf("INTERNAL SERVER WAITING", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center") | love.graphics.printf("INTERNAL SERVER WAITING", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center") | ||||
| love.graphics.printf(myip, 0, VIRTUAL_HEIGHT / 2 + 120, VIRTUAL_WIDTH, "center") | love.graphics.printf(myip, 0, VIRTUAL_HEIGHT / 2 + 120, VIRTUAL_WIDTH, "center") | ||||
| end | end | ||||
| if isAndroid then | |||||
| androidDraw() | |||||
| love.keyboard.mouseisReleased = false | |||||
| end | |||||
| simpleScale.unSet() | simpleScale.unSet() | ||||
| end | end | ||||
| @@ -1662,6 +1688,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
| end | end | ||||
| if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q") or doubleclick1) then | if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q") or doubleclick1) then | ||||
| TEXT = "Lets Begin!" | TEXT = "Lets Begin!" | ||||
| doubleclick1 = false | |||||
| ball_DIR = 1 | ball_DIR = 1 | ||||
| if maxBalls == 1 then | if maxBalls == 1 then | ||||
| ball[1]:reset(1, 1) | ball[1]:reset(1, 1) | ||||
| @@ -1684,6 +1711,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
| end | end | ||||
| if (AGAINST_AI == 1) then | if (AGAINST_AI == 1) then | ||||
| TEXT = "" | TEXT = "" | ||||
| doubleclick2 = false | |||||
| ball_DIR = -1 | ball_DIR = -1 | ||||
| if maxBalls == 1 then | if maxBalls == 1 then | ||||
| ball[2]:reset(i, 2) | ball[2]:reset(i, 2) | ||||
| @@ -1698,6 +1726,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE | |||||
| end | end | ||||
| if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")) or doubleclick2)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" | TEXT = "Lets Begin" | ||||
| doubleclick2 = false | |||||
| ball_DIR = -1 | ball_DIR = -1 | ||||
| if maxBalls == 1 then | if maxBalls == 1 then | ||||
| ball[1]:reset(1, 2) | ball[1]:reset(1, 2) | ||||
| @@ -1757,6 +1786,9 @@ function resettinggenius() | |||||
| ts = 0 | ts = 0 | ||||
| originalSpeed = 200 | originalSpeed = 200 | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball_DIR = 1 | |||||
| ball[1].dy = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| gameMode = "normal" | gameMode = "normal" | ||||
| player1.height = 100 | player1.height = 100 | ||||
| @@ -1795,7 +1827,7 @@ end | |||||
| function ballsAlive() | function ballsAlive() | ||||
| for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
| if ball[i].disabled == false then | if ball[i].disabled == false then | ||||
| print("Ball " .. i .. " is not disabled") | |||||
| --print("Ball " .. i .. " is not disabled") | |||||
| return true | return true | ||||
| end | end | ||||
| end | end | ||||
| @@ -1815,32 +1847,32 @@ function checkCurrentServer(dt) | |||||
| end | end | ||||
| if GetIPType(IP) == 1 then | if GetIPType(IP) == 1 then | ||||
| if dserverinit == false then | if dserverinit == false then | ||||
| print("Switching IP") | |||||
| --print("Switching IP") | |||||
| socket = require "socket" | socket = require "socket" | ||||
| address, port = IP, 12345 | address, port = IP, 12345 | ||||
| print(address) | |||||
| --print(address) | |||||
| udp = socket.udp() | udp = socket.udp() | ||||
| udp:setpeername(address, port) | udp:setpeername(address, port) | ||||
| udp:settimeout(0) | udp:settimeout(0) | ||||
| dserverinit = true | dserverinit = true | ||||
| end | end | ||||
| if IP ~= address then dserverinit = false print(IP .. " doesnt equal " .. address) | |||||
| if IP ~= address then dserverinit = false--print(IP .. " doesnt equal " .. address) | |||||
| else | else | ||||
| ts = ts + dt | ts = ts + dt | ||||
| --print(ts) | --print(ts) | ||||
| if ts > checkrate then | if ts > checkrate then | ||||
| status = "offline" | status = "offline" | ||||
| print("sent ping") | |||||
| --print("sent ping") | |||||
| udp:send("HELLO") | udp:send("HELLO") | ||||
| local data | local data | ||||
| data = udp:receive() | data = udp:receive() | ||||
| if data then | if data then | ||||
| print("got answer!") | |||||
| --print("got answer!") | |||||
| local p = split(data, '|') | local p = split(data, '|') | ||||
| status = p[1] | status = p[1] | ||||
| print("answer is " .. status) | |||||
| --print("answer is " .. status) | |||||
| else | else | ||||
| print("no response!") | |||||
| --print("no response!") | |||||
| end | end | ||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| @@ -1859,7 +1891,7 @@ local p2ping = 0 | |||||
| local requesterip | local requesterip | ||||
| local requresterport | local requresterport | ||||
| function selfHost(dt) | function selfHost(dt) | ||||
| print("Server running") | |||||
| --print("Server running") | |||||
| if not hostinit then | if not hostinit then | ||||
| local socket = require('socket') | local socket = require('socket') | ||||
| udp = socket.udp() | udp = socket.udp() | ||||
| @@ -1884,11 +1916,11 @@ end | |||||
| if data then | if data then | ||||
| if data == "HELLO" then | if data == "HELLO" then | ||||
| print("getting pinged") | |||||
| --print("getting pinged") | |||||
| requesterip = msg_or_ip | requesterip = msg_or_ip | ||||
| requesterport = port_or_nil | requesterport = port_or_nil | ||||
| else | else | ||||
| print(string.sub(data,1,1) .. "Playerlist: " .. player1ip .. " " .. player2ip) | |||||
| --print(string.sub(data,1,1) .. "Playerlist: " .. player1ip .. " " .. player2ip) | |||||
| if player2ip == msg_or_ip then | if player2ip == msg_or_ip then | ||||
| p2data = data .. '|' .. p2ping | p2data = data .. '|' .. p2ping | ||||
| p2ping = 0 | p2ping = 0 | ||||
| @@ -1898,9 +1930,9 @@ end | |||||
| p2data = data .. '|' .. p2ping | p2data = data .. '|' .. p2ping | ||||
| p2ping = 0 | p2ping = 0 | ||||
| player2port = port_or_nil | player2port = port_or_nil | ||||
| print("CONNECTED: PLAYER 2 FROM: " .. player2ip) | |||||
| --print("CONNECTED: PLAYER 2 FROM: " .. player2ip) | |||||
| elseif (player1ip ~= msg_or_ip and player2ip ~= msg_or_ip) then | elseif (player1ip ~= msg_or_ip and player2ip ~= msg_or_ip) then | ||||
| print("Lobby Full!" .. player1ip .. player2ip) | |||||
| --print("Lobby Full!" .. player1ip .. player2ip) | |||||
| end | end | ||||
| end | end | ||||
| @@ -1913,7 +1945,7 @@ end | |||||
| if player2ip == "none" then | if player2ip == "none" then | ||||
| confirmation = "S" | confirmation = "S" | ||||
| else | else | ||||
| print("Player2: " .. player2ip) | |||||
| --print("Player2: " .. player2ip) | |||||
| p2ping = p2ping + 1 | p2ping = p2ping + 1 | ||||
| if p2ping > 100 then | if p2ping > 100 then | ||||
| for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
| @@ -1934,11 +1966,12 @@ end | |||||
| '|' .. tostring(ballSpeed) .. | '|' .. tostring(ballSpeed) .. | ||||
| '|' .. tostring(paddle_SPEED) .. | '|' .. tostring(paddle_SPEED) .. | ||||
| '|' .. tostring(player1striken) .. | '|' .. tostring(player1striken) .. | ||||
| '|' .. tostring(areanuclear) .. | |||||
| "|HOST|".. p2ping, player2ip, player2port) | "|HOST|".. p2ping, player2ip, player2port) | ||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| end | end | ||||
| print("PLAYER 2 DISCONNECTED") | |||||
| --print("PLAYER 2 DISCONNECTED") | |||||
| p2data = nil | p2data = nil | ||||
| player2ip = "none" | player2ip = "none" | ||||
| player2port = nil | player2port = nil | ||||
| @@ -1963,24 +1996,25 @@ end | |||||
| '|' .. tostring(ballSpeed) .. | '|' .. tostring(ballSpeed) .. | ||||
| '|' .. tostring(paddle_SPEED) .. | '|' .. tostring(paddle_SPEED) .. | ||||
| '|' .. tostring(player1striken) .. | '|' .. tostring(player1striken) .. | ||||
| '|' .. tostring(areanuclear) .. | |||||
| "|HOST|".. p2ping, player2ip, player2port) | "|HOST|".. p2ping, player2ip, player2port) | ||||
| ts = 0 | ts = 0 | ||||
| end | end | ||||
| end | end | ||||
| print("SENT TO " .. player2ip .. ":" .. player2port .. " : " ..lastSentKey) | |||||
| --print("SENT TO " .. player2ip .. ":" .. player2port .. " : " ..lastSentKey) | |||||
| end | end | ||||
| local datanumtest = 0 | local datanumtest = 0 | ||||
| local datawaspassed = false | local datawaspassed = false | ||||
| if p2data and player1port then | if p2data and player1port then | ||||
| datawaspassed = true | datawaspassed = true | ||||
| print("ReceivedINFO: " .. p2data) | |||||
| --print("ReceivedINFO: " .. p2data) | |||||
| confirmation = "N" | confirmation = "N" | ||||
| local p = split(p2data, '|') | local p = split(p2data, '|') | ||||
| if p[16] then | |||||
| if tonumber(p[17]) > 90 then | |||||
| if p[17] then | |||||
| if tonumber(p[18]) > 90 then | |||||
| confirmation = "L" | confirmation = "L" | ||||
| end | end | ||||
| if p[16] ~= "CLIENT" then | |||||
| if p[17] ~= "CLIENT" then | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| elseif p[1] == "RESPONSE" then | elseif p[1] == "RESPONSE" then | ||||
| @@ -1994,10 +2028,10 @@ end | |||||
| confirmation = "U" | confirmation = "U" | ||||
| end | end | ||||
| if p[16] then | |||||
| if p[17] then | |||||
| if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then | if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then | ||||
| ball[1].disabled = false | ball[1].disabled = false | ||||
| print("illegal disabling") | |||||
| --print("illegal disabling") | |||||
| end | end | ||||
| if gameState ~= "1serve" then | if gameState ~= "1serve" then | ||||
| if (ball[1].x > VIRTUAL_WIDTH/2) then | if (ball[1].x > VIRTUAL_WIDTH/2) then | ||||
| @@ -2015,10 +2049,11 @@ end | |||||
| gameState, | gameState, | ||||
| ball[1].dx, | ball[1].dx, | ||||
| ballSpeed, | ballSpeed, | ||||
| 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") | |||||
| paddle_SPEED, player2striken, | |||||
| areanuclear = 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]), tonumber(p[16]) | |||||
| --print("ACCEPTED") | |||||
| else | else | ||||
| print("DECLINED") | |||||
| --print("DECLINED") | |||||
| end | end | ||||
| else | else | ||||
| if tonumber(p[9]) > VIRTUAL_WIDTH/2 then | if tonumber(p[9]) > VIRTUAL_WIDTH/2 then | ||||
| @@ -2035,10 +2070,11 @@ end | |||||
| gameState, | gameState, | ||||
| ball[1].dx, | ball[1].dx, | ||||
| ballSpeed, | ballSpeed, | ||||
| 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") | |||||
| paddle_SPEED, player2striken, | |||||
| areanuclear = 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]), tonumber(p[16]) | |||||
| --print("ACCEPTED") | |||||
| else | else | ||||
| print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx) | |||||
| --print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx) | |||||
| lastSentKeyClient = p[1] | lastSentKeyClient = p[1] | ||||
| player2.y = tonumber(p[4]) | player2.y = tonumber(p[4]) | ||||
| player2striken = tonumber(p[15]) | player2striken = tonumber(p[15]) | ||||
| @@ -2046,20 +2082,20 @@ end | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| print("SENT TO " .. player1ip .. ":" .. player1port .. " : " .. string.sub(p2data,1,1)) | |||||
| --print("SENT TO " .. player1ip .. ":" .. player1port .. " : " .. string.sub(p2data,1,1)) | |||||
| --print("1::" .. p1data) | --print("1::" .. p1data) | ||||
| --print("2::" .. p2data) | --print("2::" .. p2data) | ||||
| --print("SENT1: " .. player2ip .. " " .. player2port .. " " .. p1data) | --print("SENT1: " .. player2ip .. " " .. player2port .. " " .. p1data) | ||||
| --print("SENT2: " .. player1ip .. " " .. player1port .. " " .. p2data) | --print("SENT2: " .. player1ip .. " " .. player1port .. " " .. p2data) | ||||
| end | end | ||||
| if requesterip then | if requesterip then | ||||
| print("getting pnged!") | |||||
| --print("getting pnged!") | |||||
| if player2ip == "none" then | if player2ip == "none" then | ||||
| udp:sendto("clienttest", requesterip, requesterport) | udp:sendto("clienttest", requesterip, requesterport) | ||||
| print("clienttest av to: " .. requesterip) | |||||
| --print("clienttest av to: " .. requesterip) | |||||
| else | else | ||||
| udp:sendto("full", requesterip, requesterport) | udp:sendto("full", requesterip, requesterport) | ||||
| print("full to: " .. msg_or_ip) | |||||
| --print("full to: " .. msg_or_ip) | |||||
| end | end | ||||
| requesterip, requesterport = nil | requesterip, requesterport = nil | ||||
| end | end | ||||
| @@ -2111,6 +2147,9 @@ function love.touchreleased( id, x, y, dx, dy, pressure ) | |||||
| if gameState == "start" then | if gameState == "start" then | ||||
| resettinggenius() | resettinggenius() | ||||
| gameState = "menu" | gameState = "menu" | ||||
| ball[1].dx = 1 | |||||
| ball_DIR = 1 | |||||
| ball[1].dy = 1 | |||||
| globalState = "menu" | globalState = "menu" | ||||
| hardmanager() | hardmanager() | ||||
| @@ -2137,6 +2176,7 @@ function love.touchmoved( id, x, y, dx, dy, pressure ) | |||||
| if touches[existsingID].x - touches[existsingID].originalX > 200 and | if touches[existsingID].x - touches[existsingID].originalX > 200 and | ||||
| touches[existsingID].originalX > VIRTUAL_WIDTH/2 then | touches[existsingID].originalX > VIRTUAL_WIDTH/2 then | ||||
| hold2 = true | hold2 = true | ||||
| lastSentKey = p2control.counter | lastSentKey = p2control.counter | ||||
| else | else | ||||
| hold2 = false | hold2 = false | ||||
| @@ -105,8 +105,13 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds | |||||
| if (hot == i) then | if (hot == i) then | ||||
| color = {10, 10, 0, 255} | color = {10, 10, 0, 255} | ||||
| end | end | ||||
| button.now = love.keyboard.mouseWasReleased() | |||||
| if button.now and not button.last and hot == i then | |||||
| --print(love.keyboard.mouseisReleased) | |||||
| button.now = love.keyboard.mouseisReleased | |||||
| if location == "android" then | |||||
| button.now = love.mouse.isDown(1) | |||||
| end | |||||
| if button.now and hot == i then | |||||
| love.graphics.setColor(0,0,0,1) | love.graphics.setColor(0,0,0,1) | ||||
| love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) | love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) | ||||
| sounds['wallhit']:play() | sounds['wallhit']:play() | ||||
| @@ -183,6 +188,7 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| love.keyboard.mouseisReleased = false | |||||
| end | end | ||||
| function mainMenu:addButton(text, fn) | function mainMenu:addButton(text, fn) | ||||
| return { | return { | ||||
| @@ -18,7 +18,7 @@ function musicController(orders, toggling) | |||||
| sounds['gayTheme']:setVolume(0.5) | sounds['gayTheme']:setVolume(0.5) | ||||
| sounds['gayTheme']:play() | sounds['gayTheme']:play() | ||||
| elseif gameState == 'play' and player1score > ptw-2 or player2score > ptw-2 and areanuclear == 0 then | elseif gameState == 'play' and player1score > ptw-2 or player2score > ptw-2 and areanuclear == 0 then | ||||
| print(ptw-2) | |||||
| --print(ptw-2) | |||||
| sounds['gayTheme']:stop() | sounds['gayTheme']:stop() | ||||
| sounds['gayTheme3']:stop() | sounds['gayTheme3']:stop() | ||||
| sounds['updateMusic']:stop() | sounds['updateMusic']:stop() | ||||
| @@ -27,7 +27,7 @@ function musicController(orders, toggling) | |||||
| sounds['gayTheme2']:setVolume(0.5) | sounds['gayTheme2']:setVolume(0.5) | ||||
| sounds['gayTheme2']:play() | sounds['gayTheme2']:play() | ||||
| elseif gameState == 'play' and player1score > ptw-5 or player2score > ptw-5 and areanuclear == 0 then | elseif gameState == 'play' and player1score > ptw-5 or player2score > ptw-5 and areanuclear == 0 then | ||||
| print(ptw-4) | |||||
| --print(ptw-4) | |||||
| sounds['gayTheme']:stop() | sounds['gayTheme']:stop() | ||||
| sounds['gayTheme2']:stop() | sounds['gayTheme2']:stop() | ||||
| sounds['updateMusic']:stop() | sounds['updateMusic']:stop() | ||||
| @@ -14,9 +14,20 @@ function paddle:init(x, y, width, height, player) | |||||
| self.velocity = 0 | self.velocity = 0 | ||||
| self.shadowbonus = 0 | self.shadowbonus = 0 | ||||
| self.player = player | self.player = player | ||||
| self.goal = -1 | |||||
| end | end | ||||
| function paddle:update(dt) | function paddle:update(dt) | ||||
| if self.goal ~= -1 then | |||||
| if self.y+self.height/2 - self.goal > 10 then | |||||
| self.dy = -paddle_SPEED | |||||
| elseif self.goal - (self.y+self.height/2) > 10 then | |||||
| self.dy = paddle_SPEED | |||||
| else | |||||
| self.dy = 0 | |||||
| end | |||||
| end | |||||
| --love.window.setTitle(tostring(player1.velocity * dt) .. " " .. tostring(player1.dy) .. " " .. tostring(dt) ) | --love.window.setTitle(tostring(player1.velocity * dt) .. " " .. tostring(player1.dy) .. " " .. tostring(dt) ) | ||||
| if areanuclear == 0 then | if areanuclear == 0 then | ||||
| self.RED = 1 | self.RED = 1 | ||||
| @@ -67,6 +78,7 @@ function paddle:update(dt) | |||||
| end | end | ||||
| end | end | ||||
| @@ -3,26 +3,42 @@ function AI(target, ballCnt, diff) | |||||
| --print("CLOSEST TARGET IS " .. currentTarget) | --print("CLOSEST TARGET IS " .. currentTarget) | ||||
| if diff < 1200 then | if diff < 1200 then | ||||
| --print ("Normal targeting ".. currentTarget .. " " .. target.x - ball[currentTarget].x .. " " .. ball[currentTarget].y - target.y) | --print ("Normal targeting ".. currentTarget .. " " .. target.x - ball[currentTarget].x .. " " .. ball[currentTarget].y - target.y) | ||||
| if (ball[currentTarget].y - target.y >= target.height and target.x - ball[currentTarget].x < diff) then | |||||
| if (ball[currentTarget].y - target.y >= target.height and math.abs(target.x - ball[currentTarget].x) < diff) then | |||||
| target.dy = AI_SPEED | target.dy = AI_SPEED | ||||
| elseif (target.y - ball[currentTarget].y >= -target.height/2 and target.x - ball[currentTarget].x < diff) then | |||||
| elseif (target.y - ball[currentTarget].y >= -target.height/2 and math.abs(target.x - ball[currentTarget].x) < diff) then | |||||
| target.dy = -AI_SPEED | target.dy = -AI_SPEED | ||||
| else | else | ||||
| target.dy = 0 | target.dy = 0 | ||||
| end | end | ||||
| else | else | ||||
| --print("Complex targeting") | --print("Complex targeting") | ||||
| if target.x < 100 then | |||||
| neededTarget = predictBall(ball[currentTarget], target.x) | neededTarget = predictBall(ball[currentTarget], target.x) | ||||
| --print(target.x .. " found " .. neededTarget) | |||||
| if neededTarget ~= -1 then | if neededTarget ~= -1 then | ||||
| --print("Calculated target = " .. neededTarget) | --print("Calculated target = " .. neededTarget) | ||||
| if (target.y - neededTarget >= -target.height/2) then | |||||
| if (target.y + target.height/2 - neededTarget >= 15) then | |||||
| target.dy = -AI_SPEED | target.dy = -AI_SPEED | ||||
| elseif (neededTarget - target.y >= target.height*0.9) then | elseif (neededTarget - target.y >= target.height*0.9) then | ||||
| target.dy = AI_SPEED | target.dy = AI_SPEED | ||||
| else | else | ||||
| target.dy = 0 | target.dy = 0 | ||||
| end | end | ||||
| end | |||||
| else | |||||
| neededTarget1 = predictBall(ball[currentTarget], target.x) | |||||
| --print(target.x .. " found " .. neededTarget) | |||||
| if neededTarget1 ~= -1 then | |||||
| --print("Calculated target = " .. neededTarget) | |||||
| if (target.y + target.height/2 - neededTarget1 >= 10) then | |||||
| target.dy = -AI_SPEED | |||||
| elseif (neededTarget1 - (target.y+target.height/2) >= 10) then | |||||
| target.dy = AI_SPEED | |||||
| else | |||||
| target.dy = 0 | |||||
| end | |||||
| end | |||||
| end | end | ||||
| end | end | ||||
| if | if | ||||
| @@ -79,10 +95,13 @@ function evaluateClosestBall(target) | |||||
| end | end | ||||
| function predictBall(target, px) | function predictBall(target, px) | ||||
| --print("BALLSTATS:" .. target.x .. " " .. target.y) | --print("BALLSTATS:" .. target.x .. " " .. target.y) | ||||
| if target.dx > 0 then | |||||
| if target.dx > 0 and px > 100 then | |||||
| local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) | local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) | ||||
| return ans | return ans | ||||
| else | |||||
| elseif target.dx < 0 and px < 100 then | |||||
| local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) | |||||
| return ans | |||||
| else | |||||
| --print("GO TO CENTER!!") | --print("GO TO CENTER!!") | ||||
| return VIRTUAL_HEIGHT/2 | return VIRTUAL_HEIGHT/2 | ||||
| end | end | ||||
| @@ -91,10 +110,12 @@ function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) | |||||
| if (edy > 0) then | if (edy > 0) then | ||||
| --print ("normal" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | --print ("normal" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | ||||
| local time = (VIRTUAL_HEIGHT-40-ey) / (ballSpeed * edy) | local time = (VIRTUAL_HEIGHT-40-ey) / (ballSpeed * edy) | ||||
| local distance = (ballSpeed * edx) * time | |||||
| --print(distance .. " " .. edx .. " " .. time .. " " .. (px-ex)) | |||||
| if distance > (px - ex) then | |||||
| local anstime = (px - ex) / (ballSpeed * edx) | |||||
| local distance = math.abs(ballSpeed * edx) * time | |||||
| print("DOWNWARD" .. distance .. " " .. edx .. " " .. time .. " " .. math.abs(px-ex)) | |||||
| if distance > math.abs(px - ex) then | |||||
| print("QQ") | |||||
| local anstime = math.abs(px - ex) / math.abs(ballSpeed * edx) | |||||
| local bonus = (ballSpeed * edy) * anstime | local bonus = (ballSpeed * edy) * anstime | ||||
| --print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) | --print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) | ||||
| -- if (ifspecial == 0) then | -- if (ifspecial == 0) then | ||||
| @@ -106,9 +127,12 @@ function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) | |||||
| -- return -1 | -- return -1 | ||||
| --end | --end | ||||
| else | else | ||||
| local emulatedx = ex + distance | |||||
| print("SS") | |||||
| local emulatedx = ex + distance * edx | |||||
| local emulatedy = VIRTUAL_HEIGHT-40 | local emulatedy = VIRTUAL_HEIGHT-40 | ||||
| print("EMULATED: " .. emulatedx .. " " .. emulatedy) | |||||
| local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | ||||
| print("GOT EMULATION RESULT AS " .. answer) | |||||
| --love.window.setTitle(tostring(answer) .. "recursive calc bottom") | --love.window.setTitle(tostring(answer) .. "recursive calc bottom") | ||||
| return answer | return answer | ||||
| end | end | ||||
| @@ -117,16 +141,16 @@ function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) | |||||
| else | else | ||||
| --print ("inverse" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | --print ("inverse" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | ||||
| local time = (ey) / math.abs((ballSpeed * edy)) | local time = (ey) / math.abs((ballSpeed * edy)) | ||||
| local distance = (ballSpeed * edx) * time | |||||
| --print(distance .. " " .. edx .. " " .. time .. " " .. (px-ex)) | |||||
| local distance = math.abs(ballSpeed * edx) * time | |||||
| print("UPWARD" .. distance .. " " .. edx .. " " .. time .. " " .. math.abs(px-ex)) | |||||
| --print("Why th efuck ") | --print("Why th efuck ") | ||||
| if distance > (px - ex) then | |||||
| local anstime = (px - ex) / (ballSpeed * edx) | |||||
| if distance > math.abs(px - ex) then | |||||
| local anstime = math.abs(px - ex) / math.abs(ballSpeed * edx) | |||||
| local bonus = (ballSpeed * edy) * anstime | local bonus = (ballSpeed * edy) * anstime | ||||
| --print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) | |||||
| print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. math.abs(px-ex)) | |||||
| -- if (ifspecial == 0) then | -- if (ifspecial == 0) then | ||||
| local answer = ey + bonus | local answer = ey + bonus | ||||
| --love.window.setTitle(tostring(answer) .. "Basiccalc") | --love.window.setTitle(tostring(answer) .. "Basiccalc") | ||||
| @@ -135,7 +159,7 @@ function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) | |||||
| -- return -1 | -- return -1 | ||||
| -- end | -- end | ||||
| else | else | ||||
| local emulatedx = ex + distance | |||||
| local emulatedx = ex + distance * edx | |||||
| local emulatedy = 0 | local emulatedy = 0 | ||||
| ----print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (VIRTUAL_WIDTH-ex)) | ----print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (VIRTUAL_WIDTH-ex)) | ||||
| local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | ||||
| @@ -43,7 +43,7 @@ function basegame(dt) | |||||
| if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then | if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then | ||||
| --print("Calling animation") | --print("Calling animation") | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| superanimator("tensehit", 1) | superanimator("tensehit", 1) | ||||
| end | end | ||||
| if gameMode == "practice" then | if gameMode == "practice" then | ||||
| @@ -75,7 +75,7 @@ function basegame(dt) | |||||
| sounds["nuclearhit"]:setPitch(1) | sounds["nuclearhit"]:setPitch(1) | ||||
| sounds["nuclearhit"]:play() | sounds["nuclearhit"]:play() | ||||
| end | end | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| if areanuclear == 0 then | if areanuclear == 0 then | ||||
| superanimator("tensehit", 1) | superanimator("tensehit", 1) | ||||
| end | end | ||||
| @@ -172,7 +172,7 @@ function basegame(dt) | |||||
| (areanuclear == 0 and | (areanuclear == 0 and | ||||
| (striken == 1 and (player1score > ptw-2 or player2score > ptw-2))) | (striken == 1 and (player1score > ptw-2 or player2score > ptw-2))) | ||||
| then | then | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| superanimator("tensehit", 2) | superanimator("tensehit", 2) | ||||
| end | end | ||||
| if (ballSpeed > 200) then | if (ballSpeed > 200) then | ||||
| @@ -192,7 +192,7 @@ function basegame(dt) | |||||
| potentialnuke2 = 0 | potentialnuke2 = 0 | ||||
| player2nukescore = 0 | player2nukescore = 0 | ||||
| potentialstrike2 = 0 | potentialstrike2 = 0 | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| if areanuclear == 0 then | if areanuclear == 0 then | ||||
| superanimator("tensehit", 2) | superanimator("tensehit", 2) | ||||
| end | end | ||||
| @@ -315,7 +315,7 @@ function basegame(dt) | |||||
| --love.window.setTitle('Trying to update the ball') | --love.window.setTitle('Trying to update the ball') | ||||
| if timeIsSlow then | if timeIsSlow then | ||||
| if ballSpeed > originalSpeed / 3 then | if ballSpeed > originalSpeed / 3 then | ||||
| paddle_SPEED = 30 | |||||
| paddle_SPEED = 300 | |||||
| ballSpeed = ballSpeed / (1 + (dt * 2)) | ballSpeed = ballSpeed / (1 + (dt * 2)) | ||||
| end | end | ||||
| player1nukescore = player1nukescore - (dt * 50) | player1nukescore = player1nukescore - (dt * 50) | ||||
| @@ -333,7 +333,7 @@ function basegame(dt) | |||||
| end | end | ||||
| player2nukescore = player2nukescore - (dt * 50) | player2nukescore = player2nukescore - (dt * 50) | ||||
| if player2nukescore < 1 or ball[1].dx < 0 then | if player2nukescore < 1 or ball[1].dx < 0 then | ||||
| paddle_SPEED = 30 | |||||
| paddle_SPEED = 300 | |||||
| timeIsSlow2 = false | timeIsSlow2 = false | ||||
| player2reverbav = false | player2reverbav = false | ||||
| ballSpeed = originalSpeed | ballSpeed = originalSpeed | ||||
| @@ -390,7 +390,7 @@ function goalManager() | |||||
| paddle_SPEED = ballSpeed | paddle_SPEED = ballSpeed | ||||
| end | end | ||||
| AI_SPEED = difficultyl / 10 | |||||
| AI_SPEED = difficultyl | |||||
| for i = 1, maxBalls do | for i = 1, maxBalls do | ||||
| ball[i]:reset(i, 2) | ball[i]:reset(i, 2) | ||||
| end | end | ||||
| @@ -511,8 +511,9 @@ function powerAvailability() | |||||
| end | end | ||||
| end | end | ||||
| end | 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 | |||||
| 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 | player2reverbav = 1 | ||||
| --print("Available counter, " .. globalState .. tostring(love.keyboard.isDown(p2control.counter))) | |||||
| if (globalState ~= "nettest" and (love.keyboard.isDown(p2control.counter) or hold2)) or lastSentKeyClient == p2control.counter then | if (globalState ~= "nettest" and (love.keyboard.isDown(p2control.counter) or hold2)) or lastSentKeyClient == p2control.counter then | ||||
| sounds["time"]:play() | sounds["time"]:play() | ||||
| player2reverbav = false | player2reverbav = false | ||||
| @@ -667,6 +668,9 @@ function menuDraw() | |||||
| love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight) | love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight) | ||||
| end | end | ||||
| end | end | ||||
| player1:render() | |||||
| player2:render() | |||||
| ball[1]:render("controlled") | |||||
| if gameState == "touchcontrols" then | if gameState == "touchcontrols" then | ||||
| if doubleclick1 or doubleclick2 then | if doubleclick1 or doubleclick2 then | ||||
| gameState = "menu" | gameState = "menu" | ||||
| @@ -780,7 +784,7 @@ function menuDraw() | |||||
| love.keyboard.mouseisReleased = false | love.keyboard.mouseisReleased = false | ||||
| end | end | ||||
| if gameState == "multiMode" then | if gameState == "multiMode" then | ||||
| mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount") | |||||
| mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "middle") | |||||
| love.keyboard.mouseisReleased = false | love.keyboard.mouseisReleased = false | ||||
| end | end | ||||
| if gameState == "prdiff" then | if gameState == "prdiff" then | ||||
| @@ -792,6 +796,7 @@ function menuDraw() | |||||
| love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5) | love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5) | ||||
| love.graphics.rotate(rotation) | love.graphics.rotate(rotation) | ||||
| love.graphics.setFont(smallfont) | love.graphics.setFont(smallfont) | ||||
| love.graphics.setColor(200/255, 200/255, 200/255, 1) | |||||
| if isAndroid then | if isAndroid then | ||||
| love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8) | love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8) | ||||
| else | else | ||||
| @@ -819,9 +824,6 @@ function baseDraw() | |||||
| if gameState ~= 'animation' then | if gameState ~= 'animation' then | ||||
| --print("Drawing notanimtaion") | --print("Drawing notanimtaion") | ||||
| love.graphics.setFont(scorefont) | love.graphics.setFont(scorefont) | ||||
| if isAndroid then | |||||
| androidDraw() | |||||
| end | |||||
| menuDraw() | menuDraw() | ||||
| end | end | ||||
| end | end | ||||
| @@ -832,13 +834,9 @@ function baseDraw() | |||||
| nuclearDraw() | nuclearDraw() | ||||
| end | end | ||||
| if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then | if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then | ||||
| print("Drawing normally") | |||||
| --print("Drawing normally") | |||||
| normalDraw() | normalDraw() | ||||
| end | end | ||||
| if isAndroid then | |||||
| androidDraw() | |||||
| love.keyboard.mouseisReleased = false | |||||
| end | |||||
| end | end | ||||
| @@ -1089,13 +1087,13 @@ function clientsBaseGame(dt) | |||||
| if (lastSentKeyP1 == p1control.up) then | if (lastSentKeyP1 == p1control.up) then | ||||
| player1.dy = (paddle_SPEED + p2bonus) * -1 | player1.dy = (paddle_SPEED + p2bonus) * -1 | ||||
| print("moving player1 up") | |||||
| --print("moving player1 up") | |||||
| elseif (lastSentKeyP1 == p1control.down) then | elseif (lastSentKeyP1 == p1control.down) then | ||||
| player1.dy = paddle_SPEED + p2bonus | player1.dy = paddle_SPEED + p2bonus | ||||
| print("moving player1 down") | |||||
| --print("moving player1 down") | |||||
| else | else | ||||
| player1.dy = 0 | player1.dy = 0 | ||||
| -- print("stopping player") | |||||
| ----print("stopping player") | |||||
| end | end | ||||
| if ((love.keyboard.isDown(p2control.up) or sectortouched(1))) then | if ((love.keyboard.isDown(p2control.up) or sectortouched(1))) then | ||||
| player2.dy = (paddle_SPEED + p2bonus) * -1 | player2.dy = (paddle_SPEED + p2bonus) * -1 | ||||
| @@ -1117,7 +1115,7 @@ function clientsBaseGame(dt) | |||||
| if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then | if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then | ||||
| --print("Calling animation") | --print("Calling animation") | ||||
| superanimator("tensehit", 1) | superanimator("tensehit", 1) | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| end | end | ||||
| if gameMode == "practice" then | if gameMode == "practice" then | ||||
| player1score = player1score + 1 | player1score = player1score + 1 | ||||
| @@ -1188,7 +1186,7 @@ function clientsBaseGame(dt) | |||||
| (areanuclear == 0 and | (areanuclear == 0 and | ||||
| (striken == 1 and (player1score > ptw-2 or player2score > ptw-2))) | (striken == 1 and (player1score > ptw-2 or player2score > ptw-2))) | ||||
| then | then | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| superanimator("tensehit", 2) | superanimator("tensehit", 2) | ||||
| end | end | ||||
| if (ballSpeed > 200) then | if (ballSpeed > 200) then | ||||
| @@ -1208,7 +1206,7 @@ function clientsBaseGame(dt) | |||||
| potentialnuke2 = 0 | potentialnuke2 = 0 | ||||
| player2nukescore = 0 | player2nukescore = 0 | ||||
| potentialstrike2 = 0 | potentialstrike2 = 0 | ||||
| print("AREA NUCLEAR?" .. areanuclear) | |||||
| --print("AREA NUCLEAR?" .. areanuclear) | |||||
| if areanuclear == 0 then | if areanuclear == 0 then | ||||
| superanimator("tensehit", 2) | superanimator("tensehit", 2) | ||||
| end | end | ||||
| @@ -1409,4 +1407,111 @@ function GetIPType(ip) | |||||
| -- if we get here, assume we've been given a random string | -- if we get here, assume we've been given a random string | ||||
| return 3 | return 3 | ||||
| end | |||||
| end | |||||
| function menuDemo(dt) | |||||
| paddle_SPEED = 200 | |||||
| ballSpeed = 200 | |||||
| if ball[1].dx > 0 then | |||||
| AI(player2, maxBalls, 1300) | |||||
| player1.goal = 360 | |||||
| elseif ball[1].dx < 0 then | |||||
| AI(player1, maxBalls, 1300) | |||||
| player2.goal = 360 | |||||
| end | |||||
| print(neededTarget, neededTarget1) | |||||
| --print("menu demo active") | |||||
| ball[1]:update(dt) | |||||
| player1:update(dt) | |||||
| player2:update(dt) | |||||
| if ball[1].x < player1.x+15 then | |||||
| player1.y = ball[1].y-player1.height | |||||
| end | |||||
| if ball[1].x > player2.x-15 then | |||||
| player2.y = ball[1].y-player2.height | |||||
| end | |||||
| if ball[1].x >= player2.x-7 then | |||||
| select = math.random(1, 2) | |||||
| if ball[1].dy < 0 then | |||||
| select = math.random(1, 5) | |||||
| if select == 1 then | |||||
| ball[1].dy = -1 | |||||
| elseif select == 2 then | |||||
| ball[1].dy = -1.2 | |||||
| elseif select == 3 then | |||||
| ball[1].dy = -1.5 | |||||
| elseif select == 4 then | |||||
| ball[1].dy = -1.8 | |||||
| elseif select == 5 then | |||||
| ball[1].dy = -2 | |||||
| end | |||||
| else | |||||
| select = math.random(1, 5) | |||||
| if select == 1 then | |||||
| ball[1].dy = 1 | |||||
| elseif select == 2 then | |||||
| ball[1].dy = 1.2 | |||||
| elseif select == 3 then | |||||
| ball[1].dy = 1.5 | |||||
| elseif select == 4 then | |||||
| ball[1].dy = 1.8 | |||||
| elseif select == 5 then | |||||
| ball[1].dy = 2 | |||||
| end | |||||
| 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 | |||||
| select = math.random(1, 2) | |||||
| if ball[1].dy < 0 then | |||||
| select = math.random(1, 5) | |||||
| if select == 1 then | |||||
| ball[1].dy = -1 | |||||
| elseif select == 2 then | |||||
| ball[1].dy = -1.2 | |||||
| elseif select == 3 then | |||||
| ball[1].dy = -1.5 | |||||
| elseif select == 4 then | |||||
| ball[1].dy = -1.8 | |||||
| elseif select == 5 then | |||||
| ball[1].dy = -2 | |||||
| end | |||||
| else | |||||
| select = math.random(1, 5) | |||||
| if select == 1 then | |||||
| ball[1].dy = 1 | |||||
| elseif select == 2 then | |||||
| ball[1].dy = 1.2 | |||||
| elseif select == 3 then | |||||
| ball[1].dy = 1.5 | |||||
| elseif select == 4 then | |||||
| ball[1].dy = 1.8 | |||||
| elseif select == 5 then | |||||
| ball[1].dy = 2 | |||||
| end | |||||
| 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 | |||||
| soundtype = love.math.random(1, 5) | |||||
| sounds["wallhit"]:setPitch(ballSpeed / 250) | |||||
| sounds["wallhit"]:play() | |||||
| ball[1].y = 0 | |||||
| ball[1].dy = -ball[1].dy | |||||
| end | |||||
| -- -4 to account for the ball's size | |||||
| if ball[1].y >= VIRTUAL_HEIGHT - 40 then | |||||
| soundtype = love.math.random(1, 5) | |||||
| sounds["wallhit"]:setPitch(ballSpeed / 250) | |||||
| sounds["wallhit"]:play() | |||||
| ball[1].y = VIRTUAL_HEIGHT - 40 | |||||
| ball[1].dy = -ball[1].dy | |||||
| end | |||||
| end | |||||
| @@ -2,4 +2,3 @@ VIRTUAL_WIDTH = 1280 | |||||
| VIRTUAL_HEIGHT = 720 | VIRTUAL_HEIGHT = 720 | ||||
| WINDOW_WIDTH = 1280 | WINDOW_WIDTH = 1280 | ||||
| WINDOW_HEIGHT = 720 | WINDOW_HEIGHT = 720 | ||||
| isAndroid = false | |||||