From 6217df2cf71088dcf45171ca30013a53d401b7a3 Mon Sep 17 00:00:00 2001 From: madiwka3 Date: Mon, 22 Jun 2020 10:47:30 +0600 Subject: [PATCH] 0.7.1 Added hit animations --- .gitignore | 3 + animator.lua | 72 +++++++++++++++++ debuggame.sh | 5 ++ main.lua | 221 +++++---------------------------------------------- 4 files changed, 100 insertions(+), 201 deletions(-) create mode 100644 .gitignore create mode 100644 animator.lua create mode 100644 debuggame.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea740cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +conf.lua +game.love +game.zip diff --git a/animator.lua b/animator.lua new file mode 100644 index 0000000..58ba31c --- /dev/null +++ b/animator.lua @@ -0,0 +1,72 @@ +local player1anim = false +local player2anim = false +local player1animend = false +local player2animaend = false +local effectRange = {[0] = 0,[1] = 0} +local diseffectRange = {[0] = 0,[1] = 0} +function superanimator(type, param) + if type == 'tensehit' then + if param == 1 then + print("Animation called!") + player1anim = true + end + if param == 2 then + print("Animation called!") + player2anim = true + end + end +end +function staticanimatorcounter(dt) + if (player1anim) then + print("Effect range: " .. effectRange[0]) + effectRange[0] = effectRange[0] + dt*24 + if effectRange[0] > 7500/ballSpeed then + player1animend = true + end + end + if player1animend then + print("DISEffect range: " .. diseffectRange[0]) + diseffectRange[0] = diseffectRange[0] + dt*24 + if diseffectRange[0] > 50 then + effectRange[0] = 0 + diseffectRange[0] = 0 + player1anim = false + player1animend = false + end + end + if (player2anim) then + print("Effect range: " .. effectRange[1]) + effectRange[1] = effectRange[1] + dt*24 + if effectRange[1] > 7500/ballSpeed then + player2animend = true + end + end + if player2animend then + print("DISEffect range: " .. diseffectRange[1]) + diseffectRange[1] = diseffectRange[1] + dt*24 + if diseffectRange[1] > 50 then + effectRange[1] = 0 + diseffectRange[1] = 0 + player2anim = false + player2animend = false + end + end +end +function staticanimator() + if player1anim then + love.graphics.setColor(140/255,70/255,70/255,1) + love.graphics.circle("fill", player1.x, player1.y , effectRange[0]*100, 100) + end + if player1animend then + love.graphics.setColor(40/255,40/255,40/255,1) + love.graphics.circle("fill", player1.x, player1.y , diseffectRange[0]*100, 100) + end + if player2anim then + love.graphics.setColor(70/255,70/255,140/255,1) + love.graphics.circle("fill", player2.x, player2.y , effectRange[1]*100, 100) + end + if player2animend then + love.graphics.setColor(40/255,40/255,40/255,1) + love.graphics.circle("fill", player2.x, player2.y , diseffectRange[1]*100, 100) + end +end \ No newline at end of file diff --git a/debuggame.sh b/debuggame.sh new file mode 100644 index 0000000..1ab7459 --- /dev/null +++ b/debuggame.sh @@ -0,0 +1,5 @@ +rm game.love +rm game.zip +zip -r game * +mv game.zip game.love +love2d game.love \ No newline at end of file diff --git a/main.lua b/main.lua index 2282314..b1290c0 100644 --- a/main.lua +++ b/main.lua @@ -1,12 +1,14 @@ - +io.stdout:setvbuf('no') Class = require 'class' require 'paddle' require 'simpleScale' require 'TSerial' require 'eball' require 'fullScreener' +require 'superPowerControl' require 'mainMenu' require 'music' +require 'animator' local serialize = require 'ser' local shader_code = [[ vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) { @@ -16,6 +18,7 @@ vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) { ]] timeIsSlow = false timeIsSlow2 = false +debug.shake = false originalSpeed = 200 explosionRange = 0 blockinput = false @@ -140,7 +143,7 @@ function love.load() configsave = io.open('config.lua', "w") shader = love.graphics.newShader(shader_code) time_1 = 0 - + print("Debug active") --load testwalls = love.filesystem.load('save.lua')() @@ -281,7 +284,7 @@ function startShake(duration, magnitude) t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5 end function displayFPS() ---love.window.setTitle(maxBalls) +love.window.setTitle(love.timer.getFPS()) end function speedControl() @@ -291,6 +294,7 @@ function speedControl() end function love.update(dt) + staticanimatorcounter(dt) displayFPS() if areanuclear == 1 then if nuclearanimation > 0 then @@ -311,7 +315,7 @@ function love.update(dt) dangerChecker() musicController('norm', 1) palleteController() - if (gameState == 'animation') then + if (gameState == 'animation') then animator(dt) end if t < shakeDuration then @@ -564,6 +568,11 @@ end --love.window.setTitle('VOID') for i = 1, maxBalls do if ball[i]:collides(player1) then + print(debug.shake) + if ((areanuclear == 0 and ((player1striken or player2striken) and (player1score > 9 or player2score > 9))) or debug.shake) then + print("Calling animation") + superanimator('tensehit', 1) + end --gameState = 'quickanim' if gameMode == 'practice' then player1score = player1score + 1 @@ -682,85 +691,13 @@ end end end end - if ball[i]:collides(player3) then - --gameState = 'quickanim' - 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 - 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 /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 - ball[i].dy = math.random(-2, -1) - elseif love.keyboard.isDown(p1control.down) then - ball[i].dy = math.random(1, 2) - else - if ball[i].dy < 0 then - - ball[i].dy = math.random(-2, -1) - else - ball[i].dy = math.random(1, 2) - end - end - end if ball[i]:collides(player2) then --ameState = 'quickanim' t = 0 shakeDuration = 1 + if ((areanuclear == 0 and ((player1striken or player2striken) and (player1score > 9 or player2score > 9))) or debug.shake) then + superanimator('tensehit', 2) + end if (ballSpeed > 200) then shakeMagnitude = ballSpeed/200 else @@ -876,126 +813,6 @@ end end end end - if ball[i]:collides(player4) then - --ameState = 'quickanim' - t = 0 - shakeDuration = 1 - 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 - - 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 (love.keyboard.isDown(p2control.up) or AI_SPEED < 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 - elseif love.keyboard.isDown(p2control.down) or AI_SPEED > 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 - 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 ball[i].y <= 0 then soundtype = love.math.random(1, 5) sounds['wallhit']:setPitch(ballSpeed/250) @@ -1509,7 +1326,7 @@ function love.draw() player1:render() player2:render() elseif gameState == 'animation' then - callAnimator() + callAnimator() --This calls a fucking 100 year old animator. I dont even remember what it does. This has nothing to do with the new one else mapChanger() if t < shakeDuration then @@ -1531,6 +1348,7 @@ function love.draw() love.graphics.setShader() love.graphics.clear(40/255, 40/255, 40/255, 1) --BACKGROUND COLOR end + staticanimator() if (gameMode == 'practice') then love.graphics.rectangle('fill', VIRTUAL_WIDTH, 0, 10, VIRTUAL_HEIGHT) end @@ -1544,7 +1362,7 @@ function love.draw() if gameState == 'play' or gameState == '1serve' or gameState == '2serve' then love.graphics.setFont(smallfont) end - + 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') @@ -1592,6 +1410,7 @@ function love.draw() love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight) end end + if gameState ~= 'assign' then player1:render() player3:render()