|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692 |
- local counter = 0
- function basegame(dt)
- if gameMode == "reversegame" then
- reversegame(dt)
- end
- if player1nukescore > 300 then
- player1nukescore = 300
- end
- if player2nukescore > 300 then
- player2nukescore = 300
- end
- speedControl()
- balancer()
- effectControl()
- 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) or sectortouched(2)) then
- player1.dy = (paddle_SPEED + p1bonus) * -1
- elseif (love.keyboard.isDown(p1control.down) or sectortouched(3)) 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) or sectortouched(1))) ) then
- player2.dy = (paddle_SPEED + p2bonus) * -1
- elseif ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.down) or sectortouched(4)))) 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
- --print("inserted")
- if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then
- --print("Calling animation")
- --print("AREA NUCLEAR?" .. areanuclear)
- superanimator("tensehit", 1)
- 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
- background_scroll_speed = ballSpeed / 20
- 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.5
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- elseif (synctype == 1) then
- paddle_SPEED = ballSpeed
- 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
- background_scroll_speed = ballSpeed / 20
- end
- player1nukescore = player1nukescore + 10
- ball[i].dx = -ball[i].dx
- ball[i].x = player1.x + 30
-
- if (love.keyboard.isDown(p1control.up) or sectortouched(2)) 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) or sectortouched(3) 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*0.8 or player2score > ptw*0.8)))
- 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
- background_scroll_speed = ballSpeed / 20
- 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
- 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
- background_scroll_speed = ballSpeed / 20
- 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 sectortouched(1)) ) 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 sectortouched(4))) 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 = 300
- ballSpeed = ballSpeed / (1 + (dt * 2))
- background_scroll_speed = ballSpeed / 20
- end
- player1nukescore = player1nukescore - (dt * 50)
- if player1nukescore < 1 or ball[1].dx > 0 then
- timeIsSlow = false
- player1reverbav = false
- ballSpeed = originalSpeed
- background_scroll_speed = ballSpeed / 20
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- if timeIsSlow2 then
- if ballSpeed > originalSpeed / 3 then
- ballSpeed = ballSpeed / (1 + (dt * 2))
- background_scroll_speed = ballSpeed / 20
- end
- player2nukescore = player2nukescore - (dt * 50)
- if player2nukescore < 1 or ball[1].dx < 0 then
- paddle_SPEED = 300
- timeIsSlow2 = false
- player2reverbav = false
- ballSpeed = originalSpeed
- background_scroll_speed = ballSpeed / 20
-
- 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.9 Pacific"
- end
- dangerChecker()
- elapsed = elapsed + dt
- rotation = math.sin(elapsed * 2.5) * 0.7
-
- 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
- background_scroll_speed = ballSpeed / 20
- if (synctype == 0) then
- paddle_SPEED = ballSet
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed
- end
-
- AI_SPEED = difficultyl
- for i = 1, maxBalls do
- ball[i]:reset(i, 2)
- end
- if (player2score+1 == ptw+maxBalls-1 and gameMode ~= "practice" and not freePlay ) then
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- sounds["win"]:play()
- gameState = "done"
- TEXT = "Player 2 Won!"
- else
- if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then
- gameState = "1serve"
- serveBot()
- ball[i]:reset(i, 1)
- end
- end
- end
- sounds["score"]:play()
- 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
- background_scroll_speed = ballSpeed / 20
- if (synctype == 0) then
- paddle_SPEED = ballSet
- AI_SPEED = ballSet
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed
- AI_SPEED = ballSpeed
- end
-
- AI_SPEED = difficultyl
-
- if (player1score+1 == ptw+maxBalls-1 and not freePlay) then
- ball[i]:reset(i)
-
- sounds["win"]:play()
- gameState = "done"
- TEXT = "Player 1 Won"
- else
- if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then
- gameState = "2serve"
- serveBot()
-
- ball[i]:reset(i, 2)
- end
-
-
- end
- end
- sounds["score"]:play()
- player1score = player1score + 1
-
- end
- end
- end
-
- function powerAvailability()
- if (player1nukescore >= 20 and player1nukescore < 200) then
- potentialstrike1 = 1
- if (((globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
- player1striken = 1
- doubleclick1 = false
- player1reverbav = 0
- end
- end
- if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and (maxBalls > 1 or (ball[1].dx < 0 and ball[1].x < VIRTUAL_WIDTH/2))then
- player1reverbav = 1
- if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.counter) or hold1 == true))) then
- powerControl(1, "special")
- end
- end
- if (player1nukescore >= 200) then
- potentialnuke1 = 1
- if ((globalState == "clienttest" and (lastSentKeyP1 == p1control.super or doubleclick1 == true))or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true))) then
- sounds["nuke"]:play()
- doubleclick1 = false
- if areanuclear == 1 then
- maxspeed = maxspeed + 50
- end
- areanuclear = 1
- potentialstrike1 = 0
- striken = 0
- ballSpeed = ballSpeed * 2
- background_scroll_speed = ballSpeed / 20
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 2
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed
- 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 < 200) then
- potentialstrike2 = 1
- if (AGAINST_AI == 0) then
- if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super ) then
- player2striken = 1
- player2reverbav = 0
- doubleclick2 = false
- end
- end
- end
- 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
- 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 doubleclick2)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
- sounds["nuke"]:play()
- doubleclick2 = false
- if areanuclear == 1 then
- maxspeed = maxspeed + 50
- end
- potentialstrike2 = 0
- areanuclear = 1
- player2reverbav = 0
- ballSpeed = ballSpeed * 2
- background_scroll_speed = ballSpeed / 20
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 2
- end
- if (synctype == 1) then
- paddle_SPEED = ballSpeed
- 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 winDraw(who)
-
- love.graphics.setColor(0, 0, 0, 1)
- if who == 1 then
- love.graphics.circle("fill", player2.x, player2.y, explosionRange * 100, 100)
- love.graphics.setColor(0.7, 0.1, 0.1, 1)
- love.graphics.circle("fill", player2.x, player2.y, explosionRange * 90, 100)
- love.graphics.setColor(0.1, 0.7, 0.1, 1)
- love.graphics.circle("fill", player2.x, player2.y, explosionRange * 80, 100)
- love.graphics.setColor(0.1, 0.1, 0.7, 1)
- love.graphics.circle("fill", player2.x, player2.y, explosionRange * 70, 100)
- love.graphics.setColor(0, 0, 0, 1)
- love.graphics.circle("fill", player2.x, player2.y, explosionRange * 60, 100)
- --print("cicrleexplostion at " .. explosionRange)
- else
- love.graphics.circle("fill", player1.x, player1.y, explosionRange * 100, 100)
- love.graphics.setColor(0.7, 0.1, 0.1, 1)
- love.graphics.circle("fill", player1.x, player1.y, explosionRange * 90, 100)
- love.graphics.setColor(0.1, 0.7, 0.1, 1)
- love.graphics.circle("fill", player1.x, player1.y, explosionRange * 80, 100)
- love.graphics.setColor(0.1, 0.1, 0.7, 1)
- love.graphics.circle("fill", player1.x, player1.y, explosionRange * 70, 100)
- love.graphics.setColor(0, 0, 0, 1)
- love.graphics.circle("fill", player1.x, player1.y, explosionRange * 60, 100)
- end
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
- end
-
- function normalDraw()
- if (areanuclear == 1) then
- love.graphics.clear(1, 1, 1, 1)
- else
- love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
- if (lowcpu) then
- --love.graphics.draw(background, 0,0)
- else
- --love.graphics.draw(background, 0,-backgroundScroll)
- end
- end
- if gameState == "assign" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- for i, explosion in ipairs(explosions) do
- explosion:render()
- --print("exploding")
- 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
-
- pongDraw()
- 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.clear(30/255,30/255,30/255,1)
- 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)
- elseif 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
- player1:render()
- player2:render()
- ball[1]:render("controlled")
- if gameState == "touchcontrols" then
- if doubleclick1 or doubleclick2 then
- gameState = "menu"
- globalState = "menu"
- resettinggenius()
- end
- love.graphics.setFont(smallfont)
- love.graphics.printf("The green zones are for moving up and down, double tap the red zone for special attack or to start the serve.", 10, 150, VIRTUAL_WIDTH, "center")
- love.graphics.printf("Swipe from red to green for stopping time", 10, 450, VIRTUAL_WIDTH, "center")
- elseif gameState == "windowsettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
- love.keyboard.mouseisReleased = false
- elseif gameState == "editor" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
- love.keyboard.mouseisReleased = false
- elseif gameState == "speedSettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
- love.keyboard.mouseisReleased = false
- elseif gameState == "controlSettings" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
- love.keyboard.mouseisReleased = false
- elseif gameState == "gameMode" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- elseif gameState == "chooseIP" then
- IPselect = {}
- if isAndroid then
- table.insert(
- IPselect,
- newButton(
- IPnew,
- function()
- love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3)
- end,
- true,
- 1
- )
- )
- end
- table.insert(
- IPselect,
- newButton(
- "LANHost",
- function()
- globalState = "selfhost"
- AGAINST_AI = 0
- gameState = "1serve"
- ball[1]:reset(1, 1)
- player2.dy = 0
- end,
- true, 1
- )
- )
- table.insert(
- IPselect,
- newButton(
- "Check Server",
- function()
- IP = IPnew
- counter = 0
- end,
- true, 1
- )
- )
- if status == "offline" then
- animateConnection()
- elseif status == "nettest" and IP == IPnew then
- table.insert(
- IPselect,
- newButton(
- "Connect as Host",
- function()
- resettinggenius()
- globalState = "nettest"
- AGAINST_AI = 0
- gameState = "1serve"
- ball[1]:reset(1, 1)
- player2.dy = 0
- end,
- false, 1
- )
- )
-
- elseif status == "clienttest" and IP == IPnew then
- table.insert(
- IPselect,
- newButton(
- "Connect as Guest",
- function()
- resettinggenius()
- globalState = "clienttest"
- AGAINST_AI = 0
- gameState = "1serve"
- ball[1]:reset(1, 1)
- player2.dy = 0
- end,
- false, 1
- )
- )
- elseif status == "full" then
- love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
- love.keyboard.mouseisReleased = false
- if not isAndroid then
- love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
- end
- love.keyboard.mouseisReleased = false
- elseif gameState == "menu" then
- presence = {
- state = "Enjoying Pong",
- details = "Main Menu",
- largeImageKey = "pongnew",
- largeImageText = "Nuclear Pong",
- }
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- elseif gameState == "difficulty" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- elseif gameState == "multiMode" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- elseif gameState == "prdiff" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
- love.keyboard.mouseisReleased = false
- elseif 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.setColor(200/255, 200/255, 200/255, 1)
- if isAndroid then
- love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
- else
- love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
- end
- love.graphics.setColor(255, 255, 255, 255)
- love.graphics.pop()
- end
- end
- function baseDraw()
- love.graphics.clear(30/255,30/255,30/255,1)
- love.graphics.setColor(255, 255, 255, 1)
- if (lowcpu) then
- -- love.graphics.draw(background, 0,0)
- else
- --love.graphics.draw(background, 0,-backgroundScroll)
- end
-
- 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
- if globalState == "nettest" then
- presence = {
- state = "Enjoying Pong",
- details = "Main Menu",
- largeImageKey = "pongnew",
- largeImageText = "Nuclear Pong",
- joinSecret = IP,
- }
- end
- 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
- if gameState == 'done' and player1score > player2score then
- winDraw(1)
- elseif gameState == 'done' and player1score < player2score then
- winDraw(2)
- end
- end
- if paused then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pauseButtons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "done" then
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, doneButtons, sounds, "middle")
- love.keyboard.mouseisReleased = false
- end
- if gameState == "assign" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- end
- function androidDraw()
- --HOME BUTTON HERE
- mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, androidButtons, sounds, "android")
- if showTouchControls then
- love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
- love.graphics.rectangle("fill", 0, 0, 100, VIRTUAL_HEIGHT)
- love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH-100, 0, 50, VIRTUAL_HEIGHT)
- love.graphics.setColor(255/255, 15/255, 15/255, 0.5)
- love.graphics.rectangle("fill", 100, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH/2, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
- love.graphics.setColor(0, 0, 0, 0.5)
- love.graphics.rectangle("fill", VIRTUAL_WIDTH/2-5, 0, 10, VIRTUAL_HEIGHT)
- end
- 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.draw(background, 0,0)
-
- 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 < -10 and ball[i].disabled == false
- end
- end
- if query == "p2miss" then
- if gameMode == "reversegame" then
- return ball[i]:collides(player2)
- elseif gameMode == "normal" then
- return ball[i].x > VIRTUAL_WIDTH and ball[i].disabled == false
- end
- end
- end
- function clientsBaseGame(dt)
- if gameMode == "reverse" then
- reversegame(dt)
- end
- if player1nukescore > 300 then
- player1nukescore = 300
- end
- if player2nukescore > 300 then
- player2nukescore = 300
- end
- speedControl()
- balancer()
- effectControl()
- 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) or sectortouched(1))) then
- player2.dy = (paddle_SPEED + p2bonus) * -1
- elseif ((love.keyboard.isDown(p2control.down)) or sectortouched(4)) 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*0.8 or player2score > ptw*0.8)) 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
- background_scroll_speed = ballSpeed / 20
- 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.5
- if (synctype == 0) then
- paddle_SPEED = paddle_SPEED * 1.10
- elseif (synctype == 1) then
- paddle_SPEED = ballSpeed
- 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
- background_scroll_speed = ballSpeed / 20
- 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*0.8 or player2score > ptw*0.8)))
- 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
- background_scroll_speed = ballSpeed / 20
- 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
- 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
- background_scroll_speed = ballSpeed / 20
- 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 ((love.keyboard.isDown(p2control.up)) or sectortouched(1)) 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(p2control.down) or sectortouched(4))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 = 300
- ballSpeed = ballSpeed / (1 + (dt * 2))
- background_scroll_speed = ballSpeed / 20
- end
- player1nukescore = player1nukescore - (dt * 50)
- if player1nukescore < 1 or ball[1].dx > 0 then
- timeIsSlow = false
- player1reverbav = false
- ballSpeed = originalSpeed
- background_scroll_speed = ballSpeed / 20
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- if timeIsSlow2 then
- if ballSpeed > originalSpeed / 3 then
- ballSpeed = ballSpeed / (1 + (dt * 2))
- background_scroll_speed = ballSpeed / 20
- end
- player2nukescore = player2nukescore - (dt * 50)
- if player2nukescore < 1 or ball[1].dx < 0 then
- paddle_SPEED = 300
- timeIsSlow2 = false
- player2reverbav = false
- ballSpeed = originalSpeed
- background_scroll_speed = ballSpeed / 20
- sounds["time"]:stop()
- paddle_SPEED = originalPaddle
- end
- end
- ball[i]:update(dt)
- end
- end
- goalManager()
- powerAvailability()
- player1:update(dt)
- player2:update(dt)
- end
-
- function animateConnection()
- if GetIPType(IP) ~= 1 then
- love.graphics.printf("WRONG SYNTAX", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
- else
- counter = counter + 1 / love.timer.getFPS()
- if counter < 0.8 then
- love.graphics.printf("TRYING TO CONNECT.", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
- elseif counter < 1.6 then
- love.graphics.printf("TRYING TO CONNECT..", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
- elseif counter < 2.4 then
- love.graphics.printf("TRYING TO CONNECT...", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
- else
- love.graphics.printf("NO CONNECTION!", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
- end
- end
- end
- function GetIPType(ip)
- -- must pass in a string value
- if ip == nil or type(ip) ~= "string" then
- return 0
- end
-
- -- check for format 1.11.111.111 for ipv4
- local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
- if (#chunks == 4) then
- for _,v in pairs(chunks) do
- if (tonumber(v) < 0 or tonumber(v) > 255) then
- return 0
- end
- end
- return 1
- else
- return 0
- end
-
- -- check for ipv6 format, should be 8 'chunks' of numbers/letters
- local _, chunks = ip:gsub("[%a%d]+%:?", "")
- if chunks == 8 then
- return 2
- end
-
- -- if we get here, assume we've been given a random string
- return 3
- end
-
- function menuDemo(dt)
- paddle_SPEED = 200
- ballSpeed = 200
- background_scroll_speed = ballSpeed / 20
- 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 (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
- if ball[1].x >= player2.x-7 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- 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
- end
- if ball[1].x <= player1.x+7 then
- sounds["beep"]:setPitch(ballSpeed / 250)
- sounds["beep"]:play()
- 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
- 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
- function effectControl()
- for i, explosion in ipairs(explosions) do
- if explosion.killed then
- table.remove(explosions, i)
- --print("buried the body")
- end
- end
- end
- --[[
- THE SHIP FUNCTIONALITY HAS BEEN SCRAPPED AND WONT! BE COMING BACK.
- function shipManager(dt)
- ship_timer = ship_timer + dt
- if ship_timer > ship_goal then
- print("summoning ship")
- ship_timer = 0
- ship_goal = love.math.random(2,20)
- table.insert(ships, ship())
- end
- for k, ship in pairs(ships) do
- ship:update(dt)
-
- if ship.y < -ship.height and ship.direction == 0 then
- table.remove(ships, k)
- elseif ship.y > VIRTUAL_HEIGHT + ship.height and ship.direction == 1 then
- table.remove(ships, k)
- end
- end
- end
- ]]
|