From 8eb1c76cae95d5d69a7dbd8eef03d787f8f1e768 Mon Sep 17 00:00:00 2001 From: Madiwka3 Date: Sat, 25 Sep 2021 07:08:16 +0600 Subject: [PATCH] Fixed music and other bugs --- main.lua | 15 +++++++++++++-- music.lua | 8 ++++---- src/baseGame.lua | 16 ++++++++++++---- src/constantvars.lua | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/main.lua b/main.lua index 42c2e8a..887b741 100644 --- a/main.lua +++ b/main.lua @@ -6,7 +6,7 @@ require "src/dependencies" --print(content) --love.filesystem.write("libdiscord-rpc.so", content) if not isAndroid then -local discordRPC = require("src/discordRPC") + discordRPC = require("src/discordRPC") end local appId = require("applicationId") @@ -34,6 +34,7 @@ showTouchControls = false --0.9 VARIABLES +freePlay = false startTime = os.time(os.date("*t")) globalMessage = "none" globalAnimation = "none" @@ -295,6 +296,7 @@ function love.load() else gameState = "1serve" end + freePlay = true potentialnuke1 = 0 potentialnuke2 = 0 striken = 0 @@ -1027,7 +1029,7 @@ function startShake(duration, magnitude) t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5 end function displayFPS() - love.window.setTitle(love.timer.getFPS()) + love.window.setTitle("Nuclear Pong") --love.window.setTitle(globalState .. " " .. gameState .. " " .. paddle_SPEED .. " " .. p1bonus .. " " .. player1.dy) if love.keyboard.isDown("space") then player1nukescore = 200 @@ -2073,6 +2075,7 @@ function resolutionChanger() end function resettinggenius() maxBalls = 1 + freePlay = false for i = 1, maxBalls do ball[i]:reset(i) end @@ -2555,3 +2558,11 @@ function resetButtonX(arr) end end +function discordRPC.joinRequest(userId, username, discriminator, avatar) + print(string.format("Discord: join request (%s, %s, %s, %s)", userId, username, discriminator, avatar)) + discordRPC.respond(userId, "yes") +end + +function discordRPC.joinGame(joinSecret) + print(string.format("Discord: join (%s)", joinSecret)) +end \ No newline at end of file diff --git a/music.lua b/music.lua index 27cea33..3401100 100644 --- a/music.lua +++ b/music.lua @@ -10,7 +10,7 @@ function musicController(orders, toggling) sounds['gayTheme']:setVolume(0) sounds['gayTheme2']:setVolume(0) - elseif ((gameState == 'play' or gameState == '1serve' or gameState == '2serve') and player1score <= ptw*0.5 and player2score <= ptw*0.5 and areanuclear == 0) then + elseif ((gameState == 'play' or gameState == '1serve' or gameState == '2serve') and (player1score <= ptw*0.5 and player2score <= ptw*0.5 and areanuclear == 0) and not freePlay) then sounds['updateMusic']:stop() sounds['gayTheme2']:stop() sounds['gayTheme3']:stop() @@ -19,7 +19,7 @@ function musicController(orders, toggling) sounds['gayTheme']:setLooping(true) sounds['gayTheme']:setVolume(0.5) sounds['gayTheme']:play() - elseif gameState == 'play' and areanuclear == 0 and ((AGAINST_AI == 1 and player1score >= ptw*0.8 and player2score < ptw*0.8) or (globalState == "nettest" and player1score > ptw*0.8 and player2score <= ptw*0.8) or (globalState == "clienttest" and player2score > ptw*0.8 and player1score <= ptw*0.8)) then + elseif gameState == 'play' and areanuclear == 0 and ((AGAINST_AI == 1 and player1score >= ptw*0.8 and player2score < ptw*0.8) or (globalState == "nettest" and player1score > ptw*0.8 and player2score <= ptw*0.8) or (globalState == "clienttest" and player2score > ptw*0.8 and player1score <= ptw*0.8) and not freePlay) then --print(ptw*0.8) sounds['gayTheme']:stop() sounds['gayTheme2']:stop() @@ -29,7 +29,7 @@ function musicController(orders, toggling) sounds['gayTheme4']:setLooping(true) sounds['gayTheme4']:setVolume(0.5) sounds['gayTheme4']:play() - elseif gameState == 'play' and player1score >= ptw*0.8 or player2score > ptw*0.8 and areanuclear == 0 then + elseif gameState == 'play' and (player1score >= ptw*0.8 or player2score > ptw*0.8) and areanuclear == 0 and not freePlay then --print(ptw*0.8) sounds['gayTheme']:stop() sounds['gayTheme4']:stop() @@ -39,7 +39,7 @@ function musicController(orders, toggling) sounds['gayTheme2']:setLooping(true) sounds['gayTheme2']:setVolume(0.5) sounds['gayTheme2']:play() - elseif gameState == 'play' and player1score > ptw*0.5 or player2score > ptw*0.5 and areanuclear == 0 then + elseif gameState == 'play' and (player1score > ptw*0.5 or player2score > ptw*0.5 or freePlay) and areanuclear == 0 then --print(ptw-4) sounds['gayTheme']:stop() sounds['gayTheme2']:stop() diff --git a/src/baseGame.lua b/src/baseGame.lua index cbeaed5..5c5aa27 100644 --- a/src/baseGame.lua +++ b/src/baseGame.lua @@ -402,7 +402,7 @@ function goalManager() for i = 1, maxBalls do ball[i]:reset(i, 2) end - if (player2score+1 == ptw+maxBalls-1 and gameMode ~= "practice") then + if (player2score+1 == ptw+maxBalls-1 and gameMode ~= "practice" and not freePlay ) then for i = 1, maxBalls do ball[i]:reset(i) end @@ -417,7 +417,7 @@ function goalManager() end end end - + sounds["score"]:play() player2score = player2score + 1 end if (rules("p2miss", i)) then @@ -444,7 +444,7 @@ function goalManager() AI_SPEED = difficultyl - if (player1score+1 == ptw+maxBalls-1) then + if (player1score+1 == ptw+maxBalls-1 and not freePlay) then ball[i]:reset(i) sounds["win"]:play() @@ -900,7 +900,15 @@ function baseDraw() 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() diff --git a/src/constantvars.lua b/src/constantvars.lua index 244edca..fe18bf6 100644 --- a/src/constantvars.lua +++ b/src/constantvars.lua @@ -2,4 +2,4 @@ VIRTUAL_WIDTH = 1280 VIRTUAL_HEIGHT = 720 WINDOW_WIDTH = 1280 WINDOW_HEIGHT = 720 -isAndroid = true \ No newline at end of file +isAndroid = false \ No newline at end of file