|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- function basegame(dt)
- if gameMode == "reverse" then
- reversegame(dt)
- end
- if player1nukescore > 300 then
- player1nukescore = 300
- end
- if player2nukescore > 300 then
- player2nukescore = 300
- end
- speedControl()
- balancer()
-
- if t < shakeDuration then
- t = t + dt
- end
- --print("T = " .. tostring(t))
- serveBot()
- if gameState == 'play' then
- if (AGAINST_AI == 1) then
- AI(player2, maxBalls, AI_LEVEL)
- end
- if (love.keyboard.isDown(p1control.up)) then
- player1.dy = (paddle_SPEED + p1bonus) * -1
- elseif (love.keyboard.isDown(p1control.down)) then
- player1.dy = paddle_SPEED + p1bonus
- else
- player1.dy = 0
- end
- if (AGAINST_AI == 0) then
- if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) ) then
- player2.dy = (paddle_SPEED + p2bonus) * -1
- elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down))) then
- player2.dy = paddle_SPEED + p2bonus
- elseif (globalState ~= "nettest") then
- player2.dy = 0
- end
- end
- --print(areanuclear .. striken .. player1score .. player2score)
- for i = 1, maxBalls do
- if rules("p1hit", i) then
-
- if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
- --print("Calling animation")
- print("AREA NUCLEAR?" .. areanuclear)
- superanimator("tensehit", 1)
- end
- if gameMode == "practice" then
- player1score = player1score + 1
- end
- t = 0
- if (ballSpeed > 200) then
- shakeMagnitude = ballSpeed / 200
- else
- shakeMagnitude = 0
- end
- shakeDuration = 1
- randomtext = love.math.random(1, #textphrases)
- TEXT = textphrases[randomtext]
- soundtype = love.math.random(1, 1.2)
-
- if (player1striken == 1) then
- TEXT = "PLAYER 1 STRIKES"
- ballSpeed = ballSpeed + player1nukescore
- potentialnuke1 = 0
- player1striken = 0
- player1nukescore = 0
- potentialstrike1 = 0
- striken = 1
- if areanuclear == 0 then
- sounds["striking"]:setPitch(ballSpeed / 250)
- sounds["striking"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- print("AREA NUCLEAR?" .. areanuclear)
- if areanuclear == 0 then
- superanimator("tensehit", 1)
- end
- else
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- end
- if (striken == 1) then
-
- player1nukescore = player1nukescore * 1.2
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- elseif (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 1.10
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- ballSpeed = ballSpeed * 1.10
- end
- player1nukescore = player1nukescore + 10
- ball[i].dx = -ball[i].dx
- ball[i].x = player1.x + 30
-
- if (love.keyboard.isDown(p1control.up)) then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = -1
- elseif select == 2 then
- ball[i].dy = -1.2
- elseif select == 3 then
- ball[i].dy = -1.5
- elseif select == 4 then
- ball[i].dy = -1.8
- elseif select == 5 then
- ball[i].dy = -2
- end
- elseif love.keyboard.isDown(p1control.down) then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = 1
- elseif select == 2 then
- ball[i].dy = 1.2
- elseif select == 3 then
- ball[i].dy = 1.5
- elseif select == 4 then
- ball[i].dy = 1.8
- elseif select == 5 then
- ball[i].dy = 2
- end
- else
- if ball[i].dy < 0 then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = -1
- elseif select == 2 then
- ball[i].dy = -1.2
- elseif select == 3 then
- ball[i].dy = -1.5
- elseif select == 4 then
- ball[i].dy = -1.8
- elseif select == 5 then
- ball[i].dy = -2
- end
- else
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = 1
- elseif select == 2 then
- ball[i].dy = 1.2
- elseif select == 3 then
- ball[i].dy = 1.5
- elseif select == 4 then
- ball[i].dy = 1.8
- elseif select == 5 then
- ball[i].dy = 2
- end
- end
- end
- end
- if rules("p2hit", i) then
- --ameState = 'quickanim'
- t = 0
- shakeDuration = 1
- if
- (areanuclear == 0 and
- (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
- then
- print("AREA NUCLEAR?" .. areanuclear)
- superanimator("tensehit", 2)
- end
- if (ballSpeed > 200) then
- shakeMagnitude = ballSpeed / 200
- else
- shakeMagnitude = 0
- end
- randomtext = love.math.random(1, #textphrases)
- TEXT = textphrases[randomtext]
- soundtype = love.math.random(1, 1.2)
-
- if (player2striken == 1) then
- TEXT = "PLAYER 2 STRIKES"
- ballSpeed = ballSpeed + player2nukescore
- striken = 1
- player2striken = 0
- potentialnuke2 = 0
- player2nukescore = 0
- potentialstrike2 = 0
- print("AREA NUCLEAR?" .. areanuclear)
- if areanuclear == 0 then
- superanimator("tensehit", 2)
- end
- if areanuclear == 0 then
- sounds["striking"]:setPitch(ballSpeed / 250)
- sounds["striking"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- elseif (striken == 1) then
-
- player2nukescore = player2nukescore * 1.5
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 1.10
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- ballSpeed = ballSpeed * 1.10
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- else
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- end
- player2nukescore = player2nukescore + 10
- ball[i].dx = -ball[i].dx
- ball[i].x = player2.x - 30
-
- if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = -1
- elseif select == 2 then
- ball[i].dy = -1.2
- elseif select == 3 then
- ball[i].dy = -1.5
- elseif select == 4 then
- ball[i].dy = -1.8
- elseif select == 5 then
- ball[i].dy = -2
- end
- elseif (globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = 1
- elseif select == 2 then
- ball[i].dy = 1.2
- elseif select == 3 then
- ball[i].dy = 1.5
- elseif select == 4 then
- ball[i].dy = 1.8
- elseif select == 5 then
- ball[i].dy = 2
- end
- else
- if ball[i].dy < 0 then
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = -1
- elseif select == 2 then
- ball[i].dy = -1.2
- elseif select == 3 then
- ball[i].dy = -1.5
- elseif select == 4 then
- ball[i].dy = -1.8
- elseif select == 5 then
- ball[i].dy = -2
- end
- else
- select = math.random(1, 5)
- if select == 1 then
- ball[i].dy = 1
- elseif select == 2 then
- ball[i].dy = 1.2
- elseif select == 3 then
- ball[i].dy = 1.5
- elseif select == 4 then
- ball[i].dy = 1.8
- elseif select == 5 then
- ball[i].dy = 2
- end
- end
- end
- end
- hitIdentifier()
- if ball[i].y <= 0 then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- ball[i].y = 0
- ball[i].dy = -ball[i].dy
- end
-
- -- -4 to account for the ball's size
- if ball[i].y >= VIRTUAL_HEIGHT - 40 then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- ball[i].y = VIRTUAL_HEIGHT - 40
- ball[i].dy = -ball[i].dy
- end
- --love.window.setTitle('Trying to update the ball')
- if timeIsSlow then
- if ballSpeed > originalSpeed / 3 then
- paddle_SPEED = 30
- ballSpeed = ballSpeed / (1 + (dt * 2))
- end
- player1nukescore = player1nukescore - (dt * 50)
- if player1nukescore < 1 or ball[1].dx > 0 then
- timeIsSlow = false
- player1reverbav = false
- ballSpeed = originalSpeed
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- if timeIsSlow2 then
- if ballSpeed > originalSpeed / 3 then
- ballSpeed = ballSpeed / (1 + (dt * 2))
- end
- player2nukescore = player2nukescore - (dt * 50)
- if player2nukescore < 1 or ball[1].dx < 0 then
- paddle_SPEED = 30
- timeIsSlow2 = false
- player2reverbav = false
- ballSpeed = originalSpeed
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- ball[i]:update(dt)
- end
- end
- goalManager()
- powerAvailability()
- player1:update(dt)
- player2:update(dt)
- end
-
-
-
-
- function debugCheck(dt)
-
- if (gameState == "menu") then
- updateTEXT = "0.7.6 Chalkboard Update"
- end
- dangerChecker()
- elapsed = elapsed + dt
- rotation = math.sin(elapsed * 2.5) * 0.7
- if gameState == "assign" then
- controlChanger()
- end
- editor()
- mapChanger()
- end
-
- function goalManager()
- for i = 1, maxBalls do
- if (rules("p1miss", i)) then
- ball[i].disabled = true
- ball[i].x = 2000
-
- if ballsAlive() == false then
- if (nuckemodactive == 0) then
- areanuclear = 0
- nuclearanimation = 3
- end
- striken = 0
- player1striken = 0
- player2striken = 0
- ballSpeed = ballSet
- if (synctype == 0) then
- paddle_SPEED = ballSet / 10
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
-
- AI_SPEED = difficultyl / 10
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- if (player2score == ptw and gameMode ~= "practice") then
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- sounds["win"]:play()
- gameState = "done"
- TEXT = "Player 2 Won!"
- else
- gameState = "1serve"
- serveBot()
- end
- end
-
- player2score = player2score + 1
- end
- if (rules("p2miss", i)) then
- ball[i].disabled = true
- ball[i].x = 2000
- if ballsAlive() == false then
- if (nuckemodactive == 0) then
- areanuclear = 0
- nuclearanimation = 3
- end
- striken = 0
- player1striken = 0
- player2striken = 0
- ballSpeed = ballSet
-
- if (synctype == 0) then
- paddle_SPEED = ballSet / 10
- AI_SPEED = ballSet / 10
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- AI_SPEED = ballSpeed / 10
- end
-
- AI_SPEED = difficultyl / 10
-
- if (player1score == ptw) then
- ball[i]:reset(i)
-
- sounds["win"]:play()
- gameState = "done"
- TEXT = "Player 1 Won!"
- else
- gameState = "2serve"
-
- serveBot()
-
- ball[i]:reset(i)
- end
- end
- sounds["score"]:play()
- player1score = player1score + 1
-
- end
- end
- end
-
- function powerAvailability()
- if (player1nukescore >= 20 and player1nukescore < 140) then
- potentialstrike1 = 1
- 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 == "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 == "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
- end
- areanuclear = 1
- potentialstrike1 = 0
- striken = 0
- ballSpeed = ballSpeed * 2
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 2
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 2.2
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- player1nukescore = 0
- player1reverbav = 0
- potentialnuke1 = 0
- end
- end
- if (player2nukescore >= 20 and player2nukescore <= 140) then
- potentialstrike2 = 1
- if (AGAINST_AI == 0) then
- if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super ) then
- player2striken = 1
- player2reverbav = 0
- end
- end
- end
- if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false then
- player2reverbav = 1
- if (globalState ~= "nettest" and love.keyboard.isDown(p2control.counter)) or lastSentKeyClient == p2control.counter then
- sounds["time"]:play()
- player2reverbav = false
- timeIsSlow2 = true
- originalPaddle = paddle_SPEED
- originalSpeed = ballSpeed
- player2reverbav = 0
- potentialnuke2 = 0
- potentialstrike2 = 0
- end
- end
- if (player2nukescore >= 200) then
- potentialnuke2 = 1
- if (((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
- sounds["nuke"]:play()
- if areanuclear == 1 then
- maxspeed = maxspeed + 50
- end
- potentialstrike2 = 0
- areanuclear = 1
- player2reverbav = 0
- ballSpeed = ballSpeed * 2
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 2
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 2.2
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- player2nukescore = 0
- potentialnuke2 = 0
- end
- end
- end
-
- function editor()
- if (gameState == "editor") then
- if debug then
- --print("Editor is active!")
- end
- local mx, my = love.mouse.getPosition()
- mx = mx * DIFFERENCE_X
- my = my * DIFFERENCE_Y
- if (love.mouse.isDown(2)) then
- wallbreaker(mx, my)
- end
- if (love.mouse.isDown(3)) then
- table.insert(walls, newWall(mx, my, 10, wall1width))
- end
- end
- end
-
- function nuclearDraw()
- love.graphics.setColor(1, 1, 1, 1)
- for i = 1, maxBalls do
- love.graphics.circle("fill", ball[i].x, ball[i].y, explosionRange * 100, 100)
- end
- player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
- nuclearanimation / 3,
- nuclearanimation / 3,
- nuclearanimation / 3,
- nuclearanimation / 3,
- nuclearanimation / 3,
- nuclearanimation / 3
- for i = 1, maxBalls do
- love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
- ball[i]:render("controlled")
- end
- player1:render()
- player2:render()
- end
-
- function normalDraw()
- if (areanuclear == 1) then
- love.graphics.clear(1, 1, 1, 1)
- else
- love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
- end
- staticanimator()
-
- if MAP_TYPE == 1 then
- love.graphics.setColor(1, 0, 0.20, 1)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
- love.graphics.setColor(1, 1, 1, 1)
- end
- if MAP_TYPE == 2 then
- for i, wall in ipairs(walls) do
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
- end
- end
-
- if gameMode == 'practice' then
- practiceDraw()
- end
- if gameMode == 'normal' then
- pongDraw()
- end
- love.graphics.setFont(smallfont)
- for i = 1, maxBalls do
- if areanuclear == 1 then
- --love.window.setTitle('rendering black')
- ball[i]:render("black")
- else
- --love.window.setTitle('rendering white')
- ball[i]:render(" ")
- end
- end
-
- end
- function pongDraw()
- --print("Drawing classic pong")
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
- love.graphics.setFont(smallfont)
- love.graphics.setFont(scorefont)
- if (areanuclear == 1) then
- love.graphics.setColor(0, 0, 0, 1)
- end
- love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
- love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
- love.graphics.setColor(1, 1, 1, 1)
- displayPoints()
- player1:render()
- player2:render()
-
- end
- function practiceDraw()
- player1:render()
- love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT)
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
- love.graphics.setFont(smallfont)
- love.graphics.setFont(scorefont)
- love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
- end
- function menuDraw()
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
- love.graphics.setFont(smallfont)
- love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
- if MAP_TYPE == 1 then
- love.graphics.setColor(1, 0, 0.20, 1)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
- love.graphics.setColor(1, 1, 1, 1)
- end
- if MAP_TYPE == 2 then
- for i, wall in ipairs(walls) do
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
- end
- end
- if gameState == "windowsettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "editor" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "speedSettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "controlSettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "gameMode" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "chooseIP" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
- love.graphics.printf(IP, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "menu" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "difficulty" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "multiMode" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "prdiff" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
- love.keyboard.mouseisReleased = false
- end
- if gameState == 'start' then
- love.graphics.push()
- love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
- love.graphics.rotate(rotation)
- love.graphics.setFont(smallfont)
- love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
- love.graphics.setColor(255, 255, 255, 255)
- love.graphics.pop()
- end
- end
- function baseDraw()
- love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
- if shakeDuration > t then
-
- local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
- local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
- love.graphics.translate(dx, dy)
- end
- if globalState == 'menu' then
- --print("Drawing menuDraw")
- if gameState == 'animation' then
-
- --print("Drawing animation")
- intro()
- end
- if gameState ~= 'animation' then
- --print("Drawing notanimtaion")
- love.graphics.setFont(scorefont)
- menuDraw()
- end
- end
- if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then
- love.graphics.setFont(smallfont)
- if gameState == 'nuclearExplosion' then
- nuclearDraw()
- end
- if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
- --print("Drawing normally")
- normalDraw()
- end
-
- end
-
-
- end
-
- function renderEditor()
- if not blockinput then
- love.graphics.setColor(1, 0, 0, 1)
- love.graphics.rectangle("fill", mx, my, 10, wall1width)
- love.graphics.setColor(1, 1, 1, 1)
- end
- for i, wall in ipairs(walls) do
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
- end
- end
-
- function intro()
- love.graphics.setColor(255, 255, 255, light / 255)
- love.graphics.draw(image, 0, 0)
- end
-
-
- function displayPoints()
- love.graphics.setFont(smallfont)
- if areanuclear == 1 then
- love.graphics.setColor(0,0,0,1)
- end
- if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER
- if (player1striken == 0) then
- love.graphics.print(
- tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
- VIRTUAL_WIDTH / 2 - 500,
- VIRTUAL_HEIGHT / 60
- )
- else
- love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
- end
- elseif (player1reverbav == 1 and potentialnuke1 == 0 ) then
- love.graphics.print(
- tostring(
- math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
- ),
- VIRTUAL_WIDTH / 2 - 500,
- VIRTUAL_HEIGHT / 60
- )
- elseif (potentialnuke1 == 1) then
- love.graphics.setColor(255, 0, 0, 255)
- love.graphics.print(
- tostring(
- math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
- ),
- VIRTUAL_WIDTH / 2 - 500,
- VIRTUAL_HEIGHT / 60
- )
- love.graphics.setColor(255, 255, 255, 255)
- elseif (potentialnuke1 == 1) then
- love.graphics.setColor(255, 0, 0, 255)
- love.graphics.print(
- tostring(
- math.floor(player1nukescore) .. "[" .. p1control.super .. "]"
- ),
- VIRTUAL_WIDTH / 2 - 500,
- VIRTUAL_HEIGHT / 60
- )
- love.graphics.setColor(255, 255, 255, 255)
- else
- love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
- end
- if (potentialstrike2 == 1 and player2reverbav == 0) then
- if (player2striken == 0) then
- love.graphics.print(
- tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
- VIRTUAL_WIDTH / 2 + 430,
- VIRTUAL_HEIGHT / 60
- )
- else
- love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
- end
- elseif (potentialnuke2 == 1) then
- love.graphics.setColor(255, 0, 0, 255)
- love.graphics.print(
- tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
- VIRTUAL_WIDTH / 2 + 400,
- VIRTUAL_HEIGHT / 60
- )
- love.graphics.setColor(255, 255, 255, 255)
- elseif (potentialnuke2 == 1 and maxBalls > 1) then
- love.graphics.setColor(255, 0, 0, 255)
- love.graphics.print(
- tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
- VIRTUAL_WIDTH / 2 + 430,
- VIRTUAL_HEIGHT / 60
- )
- love.graphics.setColor(255, 255, 255, 255)
- elseif (player2reverbav == 1 and potentialnuke2 == 0 ) then
- love.graphics.print(
- tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
- VIRTUAL_WIDTH / 2 + 400,
- VIRTUAL_HEIGHT / 60
- )
- else
- love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
- end
- end
-
- function hitIdentifier()
- if (gameMode == "practice") then
- MAP_TYPE = 0
- if ball[i].x > VIRTUAL_WIDTH * 0.99 then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- if (ball[i].dx > 0) then
- ball[i].x = ball[i].x - 20
- else
- ball[i].x = ball[i].x + 20
- end
- ball[i].dx = -ball[i].dx
- end
- end
- if (MAP_TYPE == 1) then
- if
- ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
- ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
- then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- if (ball[i].dx > 0) then
- ball[i].x = ball[i].x - 20
- else
- ball[i].x = ball[i].x + 20
- end
- ball[i].dx = -ball[i].dx
- end
- if
- ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
- ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
- then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- if (ball[i].dx > 0) then
- ball[i].x = ball[i].x - 20
- else
- ball[i].x = ball[i].x + 20
- end
- ball[i].dx = -ball[i].dx
- end
- end
- if (MAP_TYPE == 2) then
- for i, wall in ipairs(walls) do
- if
- (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
- ball[1].x > wall.wallx - ballSpeed / 200 and
- ball[1].x < wall.wallx + 10 + ballSpeed / 200)
- then
- controllerSer()
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- if (ball[1].dx > 0) then
- ball[1].x = ball[1].x - 1
- else
- ball[1].x = ball[1].x + 1
- end
- ball[1].dx = -ball[1].dx
- elseif
- (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
- ball[1].x > wall.wallx and
- ball[1].x < wall.wallx + 10)
- then
- controllerSer()
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- if (ball[1].dy > 0) then
- ball[1].y = ball[1].y - 1
- else
- ball[1].y = ball[1].y + 1
- end
- ball[1].dy = -ball[1].dy
- end
- end
- end
- end
- function rules(query, i)
- if query == "p1hit" then
- if gameMode == "normal" then
- return ball[i]:collides(player1)
- elseif gameMode == "reversegame" then
- return ball[i].x < 0 and ball[i].disabled == false
- end
- end
- if query == "p2hit" then
- if gameMode == "normal" then
- return ball[i]:collides(player2)
- elseif gameMode == "reversegame" then
- return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
- end
- end
- if query == "p1miss" then
- if gameMode == "reversegame" then
- return ball[i]:collides(player1)
- elseif gameMode == "normal" then
- return ball[i].x < 0 and ball[i].disabled == false
- end
- end
- if query == "p2miss" then
- if gameMode == "reversegame" then
- return ball[i]:collides(player2)
- elseif gameMode == "normal" then
- return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
- end
- end
- end
- function clientsBaseGame(dt)
- if confirmation == "confirmed" then
- player2.RED = 0
- print("KEYS ARE: " .. confirmation .. " " .. lastSentKeyP1)
- else
- TEXT = "DISCONNECTED"
- end
- if gameMode == "reverse" then
- reversegame(dt)
- end
- if player1nukescore > 300 then
- player1nukescore = 300
- end
- if player2nukescore > 300 then
- player2nukescore = 300
- end
- speedControl()
- balancer()
-
- if t < shakeDuration then
- t = t + dt
- end
-
- if (lastSentKeyP1 == p1control.up) then
- player1.dy = (paddle_SPEED + p2bonus) * -1
- print("moving player1 up")
- elseif (lastSentKeyP1 == p1control.down) then
- player1.dy = paddle_SPEED + p2bonus
- print("moving player1 down")
- else
- player1.dy = 0
- -- print("stopping player")
- end
- if ((love.keyboard.isDown(p2control.up))) then
- player2.dy = (paddle_SPEED + p2bonus) * -1
- elseif ((love.keyboard.isDown(p2control.down))) then
- player2.dy = paddle_SPEED + p2bonus
- else
- player2.dy = 0
- end
- --print("T = " .. tostring(t))
- serveBot()
- if gameState == 'play' then
- if (AGAINST_AI == 1) then
- AI(player2, maxBalls, AI_LEVEL)
- end
- --print(areanuclear .. striken .. player1score .. player2score)
- for i = 1, maxBalls do
- if rules("p1hit", i) then
-
- if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
- --print("Calling animation")
- superanimator("tensehit", 1)
- print("AREA NUCLEAR?" .. areanuclear)
- end
- if gameMode == "practice" then
- player1score = player1score + 1
- end
- t = 0
- if (ballSpeed > 200) then
- shakeMagnitude = ballSpeed / 200
- else
- shakeMagnitude = 0
- end
- shakeDuration = 1
- randomtext = love.math.random(1, #textphrases)
- TEXT = textphrases[randomtext]
- soundtype = love.math.random(1, 1.2)
-
- if (player1striken == 1) then
- TEXT = "PLAYER 1 STRIKES"
- ballSpeed = ballSpeed + player1nukescore
- potentialnuke1 = 0
- player1striken = 0
- player1nukescore = 0
- potentialstrike1 = 0
- striken = 1
- if areanuclear == 0 then
- sounds["striking"]:setPitch(ballSpeed / 250)
- sounds["striking"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- if areanuclear == 0 then
- superanimator("tensehit", 1)
- end
- else
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- end
- if (striken == 1) then
-
- player1nukescore = player1nukescore * 1.2
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- elseif (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 1.10
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- ballSpeed = ballSpeed * 1.10
- end
- player1nukescore = player1nukescore + 10
- ball[i].dx = -ball[i].dx
- ball[i].x = player1.x + 30
- end
- if rules("p2hit", i) then
- --ameState = 'quickanim'
- t = 0
- shakeDuration = 1
- if
- (areanuclear == 0 and
- (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
- then
- print("AREA NUCLEAR?" .. areanuclear)
- superanimator("tensehit", 2)
- end
- if (ballSpeed > 200) then
- shakeMagnitude = ballSpeed / 200
- else
- shakeMagnitude = 0
- end
- randomtext = love.math.random(1, #textphrases)
- TEXT = textphrases[randomtext]
- soundtype = love.math.random(1, 1.2)
-
- if (player2striken == 1) then
- TEXT = "PLAYER 2 STRIKES"
- ballSpeed = ballSpeed + player2nukescore
- striken = 1
- player2striken = 0
- potentialnuke2 = 0
- player2nukescore = 0
- potentialstrike2 = 0
- print("AREA NUCLEAR?" .. areanuclear)
- if areanuclear == 0 then
- superanimator("tensehit", 2)
- end
- if areanuclear == 0 then
- sounds["striking"]:setPitch(ballSpeed / 250)
- sounds["striking"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- elseif (striken == 1) then
-
- player2nukescore = player2nukescore * 1.5
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed / 10
- end
- if (synctype == 0) then
- AI_SPEED = AI_SPEED * 1.10
- end
- if (synctype == 1) then
- AI_SPEED = ballSpeed * 1.1 / 10
- end
- ballSpeed = ballSpeed * 1.10
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- else
- if areanuclear == 0 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- else
- sounds["nuclearhit"]:setPitch(1)
- sounds["nuclearhit"]:play()
- end
- end
- player2nukescore = player2nukescore + 10
- ball[i].dx = -ball[i].dx
- ball[i].x = player2.x - 30
- end
- hitIdentifier()
- if ball[i].y <= 0 then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- ball[i].y = 0
-
- end
-
- -- -4 to account for the ball's size
- if ball[i].y >= VIRTUAL_HEIGHT - 40 then
- soundtype = love.math.random(1, 5)
- sounds["wallhit"]:setPitch(ballSpeed / 250)
- sounds["wallhit"]:play()
- ball[i].y = VIRTUAL_HEIGHT - 40
-
- end
- --love.window.setTitle('Trying to update the ball')
- if timeIsSlow then
- if ballSpeed > originalSpeed / 3 then
- paddle_SPEED = 30
- ballSpeed = ballSpeed / (1 + (dt * 2))
- end
- player1nukescore = player1nukescore - (dt * 50)
- if player1nukescore < 1 or ball[1].dx > 0 then
- timeIsSlow = false
- player1reverbav = false
- ballSpeed = originalSpeed
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- if timeIsSlow2 then
- if ballSpeed > originalSpeed / 3 then
- ballSpeed = ballSpeed / (1 + (dt * 2))
- end
- player2nukescore = player2nukescore - (dt * 50)
- if player2nukescore < 1 or ball[1].dx < 0 then
- paddle_SPEED = 30
- timeIsSlow2 = false
- player2reverbav = false
- ballSpeed = originalSpeed
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- ball[i]:update(dt)
- end
- end
- goalManager()
- powerAvailability()
- player1:update(dt)
- player2:update(dt)
- end
|