Browse Source

New

tags/chalkboard
madiwka3 4 years ago
parent
commit
b5eb9c6b7c
4 changed files with 1138 additions and 1393 deletions
  1. +7
    -0
      dualdebug.sh
  2. +13
    -13
      main.lua
  3. +1100
    -1361
      main2.lua
  4. +18
    -19
      src/baseGame.lua

+ 7
- 0
dualdebug.sh View File

@@ -0,0 +1,7 @@
rm game.love
rm game.zip
zip -r game *
mv game.zip game.love
love game.love &
love game.love
rm game.love

+ 13
- 13
main.lua View File

@@ -713,8 +713,7 @@ function love.update(dt)
end
if globalState == "clienttest" then
if confirmation ~= "disconnected" then
if confirmation == "up1" then lastSentKeyP2 = lastSentKeyClient lastSentKeyP1 = lastSentKey else
lastSentKeyP1 = lastSentKeyClient lastSentKeyP2 = lastSentKey end
lastSentKeyP1 = lastSentKeyClient
clientsBaseGame(dt)
end
clienttest(dt)
@@ -724,22 +723,20 @@ serverinit = false
clientinit = false
function nettest(dt)
if serverinit == false then
local socket = require('socket')
local socket = require "socket"
local address, port = "45.76.95.31", 12345
udp = socket.udp()
udp:setsockname('localhost', 142)
udp:setpeername(address, port)
udp:settimeout(0)
serverinit = true
end
data, msg_or_ip, port_or_nil = udp:receivefrom()
if data then
print(data .. "FROM " .. msg_or_ip)
end
data = udp:receive()
if data then
local p = split(data, '|')
lastSentKeyClient = p[1]
for i = 1, maxBalls do
print (tostring(ball[i].dy))
udp:sendto(tostring(lastSentKey) ..'|'.. tostring(ball[i].dy) .. '|' .. tostring(player2.y) .. '|' .. tostring(player1.y) .. '|' .. tostring(player1score) .. '|' .. tostring(player2score) .. '|' .. tostring(player1nukescore) .. '|' .. tostring(player2nukescore), msg_or_ip, port_or_nil)
udp:send(tostring(lastSentKey) ..'|'.. tostring(ball[i].dy) .. '|' .. tostring(player2.y) .. '|' .. tostring(player1.y) .. '|' .. tostring(player1score) .. '|' .. tostring(player2score) .. '|' .. tostring(player1nukescore) .. '|' .. tostring(player2nukescore) .. "|confirmed|" .. tostring(ball[i].x) .. '|' .. tostring(ball[i].y))
print("SENT: " .. lastSentKey)
end
end
@@ -763,10 +760,13 @@ function clienttest(dt)
local die = tonumber(p[2])
print(p[2])
print(p[2] + 0)
lastSentKeyClient, ball[i].dy, player2.y, player1.y, player1score, player2score, player1nukescore, player2nukescore, confirmation, gameState = p[1], die, tonumber(p[3]), tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), p[9], p[10]
print(tonumber(p[11]))
lastSentKeyClient, ball[i].dy, player2.y, player1.y, player1score, player2score, player1nukescore, player2nukescore, confirmation, ball[i].x, ball[i].y = p[1], die, tonumber(p[3]), tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), p[9], tonumber(p[10]), tonumber(p[11])
end
else
confirmation = "disconnected"
end
print(confirmation .. " recieved " .. lastSentKeyClient)
print(confirmation .. " recieved " .. lastSentKeyClient .. " AND ")

end
function wallbreaker(x, y)
@@ -1300,7 +1300,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE
if (gameMode ~= "practice") then
TEXT = "PLAYER 1, serve!(q)"
end
if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or gameMode == "practice" or (confirmation == "up1" and love.keyboard.isDown("q")) or (confirmation == "up2" and lastSentKeyP1 == "q")) then
if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q")) then
TEXT = "Lets Begin!"
ball_DIR = 1
for i = 1, maxBalls do
@@ -1322,7 +1322,7 @@ function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SE
gameState = "play"
end
if (((confirmation == "up1" and lastSentKeyP2 == "p") or ((globalState ~= "clienttest" or confirmation == "up2") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
TEXT = "Lets Begin"
ball_DIR = -1
for i = 1, maxBalls do


+ 1100
- 1361
main2.lua
File diff suppressed because it is too large
View File


+ 18
- 19
src/baseGame.lua View File

@@ -28,9 +28,9 @@ function basegame(dt)
player1.dy = 0
end
if (AGAINST_AI == 0) then
if (love.keyboard.isDown(p2control.up)) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) or lastSentKeyClient == p2control.up) then
player2.dy = (paddle_SPEED + p2bonus) * -1
elseif (love.keyboard.isDown(p2control.down)) then
elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or lastSentKeyClient == p2control.down) then
player2.dy = paddle_SPEED + p2bonus
else
player2.dy = 0
@@ -238,7 +238,7 @@ function basegame(dt)
ball[i].dx = -ball[i].dx
ball[i].x = player2.x - 30

if ((confirmation == "up2" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyP2 == p2control.up) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = -1
@@ -251,7 +251,7 @@ function basegame(dt)
elseif select == 5 then
ball[i].dy = -2
end
elseif (confirmation == "up2" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyP2 == p2control.down then
elseif (globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
select = math.random(1, 5)
if select == 1 then
ball[i].dy = 1
@@ -456,20 +456,20 @@ end
function powerAvailability()
if (player1nukescore >= 20 and player1nukescore < 140) then
potentialstrike1 = 1
if (((confirmation == "up1" and love.keyboard.isDown(p1control.super)) or (confirmation == "up2" and lastSentKeyP1 == p1control.super)) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (confirmation == "confirmed" and lastSentKeyP1 == p1control.super)) ) then
player1striken = 1
player1reverbav = 0
end
end
if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false then
player1reverbav = 1
if ((confirmation == "up1" and love.keyboard.isDown(p1control.counter)) or (confirmation == "up2" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
if ((confirmation == "confirmed" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
powerControl(1, "special")
end
end
if (player1nukescore >= 200) then
potentialnuke1 = 1
if ((confirmation == "up1" and love.keyboard.isDown(p1control.super)) or (confirmation == "up2" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
if ((confirmation == "confirmed" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
sounds["nuke"]:play()
if areanuclear == 1 then
maxspeed = maxspeed + 50
@@ -498,7 +498,7 @@ function powerAvailability()
if (player2nukescore >= 20 and player2nukescore <= 140) then
potentialstrike2 = 1
if (AGAINST_AI == 0) then
if ((confirmation == "up2" and love.keyboard.isDown(p2control.super)) or lastSentKeyP2 == p2control.super or (globalState ~= "clienttest" and love.keyboard.isDown(p2control.super))) then
if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super ) then
player2striken = 1
player2reverbav = 0
end
@@ -506,7 +506,7 @@ function powerAvailability()
end
if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false then
player2reverbav = 1
if (confirmation == "up2" and love.keyboard.isDown(p2control.counter)) or lastSentKeyP2 == p2control.counter or (globalState ~= "clienttest" and love.keyboard.isDown(p2control.counter)) then
if (globalState ~= "nettest" and love.keyboard.isDown(p2control.counter)) or lastSentKeyClient == p2control.counter then
sounds["time"]:play()
player2reverbav = false
timeIsSlow2 = true
@@ -519,7 +519,7 @@ function powerAvailability()
end
if (player2nukescore >= 200) then
potentialnuke2 = 1
if (((confirmation == "up2" and love.keyboard.isDown(p2control.super)) or lastSentKeyP2 == p2control.super or (globalState ~= "clienttest" and love.keyboard.isDown(p2control.super))) and AGAINST_AI == 0) then
if (((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
sounds["nuke"]:play()
if areanuclear == 1 then
maxspeed = maxspeed + 50
@@ -960,13 +960,12 @@ function rules(query, i)
end
end
function clientsBaseGame(dt)
if confirmation == "up1" then
player1.RED = 0
print("KEYS ARE: " .. confirmation .. " " .. lastSentKeyP2)
elseif confirmation == "up2" then
if confirmation == "confirmed" then
player2.RED = 0
print("KEYS ARE: " .. confirmation .. " " .. lastSentKeyP1)
end
else
TEXT = "DISCONNECTED"
end
if gameMode == "reverse" then
reversegame(dt)
end
@@ -983,19 +982,19 @@ function clientsBaseGame(dt)
t = t + dt
end
if ((confirmation == "up1" and love.keyboard.isDown(p1control.up)) or lastSentKeyP1 == p1control.up) then
if (lastSentKeyP1 == p1control.up) then
player1.dy = (paddle_SPEED + p2bonus) * -1
print("moving player1 up")
elseif ((confirmation == "up1" and love.keyboard.isDown(p1control.down)) or lastSentKeyP1 == p1control.down) then
elseif (lastSentKeyP1 == p1control.down) then
player1.dy = paddle_SPEED + p2bonus
print("moving player1 down")
else
player1.dy = 0
print("stopping player")
end
if ((confirmation == "up2" and love.keyboard.isDown(p2control.up)) or lastSentKeyP2 == p2control.up) then
if ((love.keyboard.isDown(p2control.up))) then
player2.dy = (paddle_SPEED + p2bonus) * -1
elseif ((confirmation == "up2" and love.keyboard.isDown(p2control.down)) or lastSentKeyP2 == p2control.down) then
elseif ((love.keyboard.isDown(p2control.down))) then
player2.dy = paddle_SPEED + p2bonus
else
player2.dy = 0


Loading…
Cancel
Save