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