Browse Source

0.7.1 Added hit animations

tags/chalkboard
madiwka3 4 years ago
parent
commit
6217df2cf7
4 changed files with 100 additions and 201 deletions
  1. +3
    -0
      .gitignore
  2. +72
    -0
      animator.lua
  3. +5
    -0
      debuggame.sh
  4. +20
    -201
      main.lua

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
conf.lua
game.love
game.zip

+ 72
- 0
animator.lua View File

@@ -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

+ 5
- 0
debuggame.sh View File

@@ -0,0 +1,5 @@
rm game.love
rm game.zip
zip -r game *
mv game.zip game.love
love2d game.love

+ 20
- 201
main.lua View File

@@ -1,12 +1,14 @@
io.stdout:setvbuf('no')
Class = require 'class' Class = require 'class'
require 'paddle' require 'paddle'
require 'simpleScale' require 'simpleScale'
require 'TSerial' require 'TSerial'
require 'eball' require 'eball'
require 'fullScreener' require 'fullScreener'
require 'superPowerControl'
require 'mainMenu' require 'mainMenu'
require 'music' require 'music'
require 'animator'
local serialize = require 'ser' local serialize = require 'ser'
local shader_code = [[ local shader_code = [[
vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) { 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 timeIsSlow = false
timeIsSlow2 = false timeIsSlow2 = false
debug.shake = false
originalSpeed = 200 originalSpeed = 200
explosionRange = 0 explosionRange = 0
blockinput = false blockinput = false
@@ -140,7 +143,7 @@ function love.load()
configsave = io.open('config.lua', "w") configsave = io.open('config.lua', "w")
shader = love.graphics.newShader(shader_code) shader = love.graphics.newShader(shader_code)
time_1 = 0 time_1 = 0
print("Debug active")
--load --load
testwalls = love.filesystem.load('save.lua')() testwalls = love.filesystem.load('save.lua')()
@@ -281,7 +284,7 @@ function startShake(duration, magnitude)
t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5 t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5
end end
function displayFPS() function displayFPS()
--love.window.setTitle(maxBalls)
love.window.setTitle(love.timer.getFPS())
end end
function speedControl() function speedControl()
@@ -291,6 +294,7 @@ function speedControl()
end end
function love.update(dt) function love.update(dt)
staticanimatorcounter(dt)
displayFPS() displayFPS()
if areanuclear == 1 then if areanuclear == 1 then
if nuclearanimation > 0 then if nuclearanimation > 0 then
@@ -311,7 +315,7 @@ function love.update(dt)
dangerChecker() dangerChecker()
musicController('norm', 1) musicController('norm', 1)
palleteController() palleteController()
if (gameState == 'animation') then
if (gameState == 'animation') then
animator(dt) animator(dt)
end end
if t < shakeDuration then if t < shakeDuration then
@@ -564,6 +568,11 @@ end
--love.window.setTitle('VOID') --love.window.setTitle('VOID')
for i = 1, maxBalls do for i = 1, maxBalls do
if ball[i]:collides(player1) then 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' --gameState = 'quickanim'
if gameMode == 'practice' then if gameMode == 'practice' then
player1score = player1score + 1 player1score = player1score + 1
@@ -682,85 +691,13 @@ end
end end
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 if ball[i]:collides(player2) then
--ameState = 'quickanim' --ameState = 'quickanim'
t = 0 t = 0
shakeDuration = 1 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 if (ballSpeed > 200) then
shakeMagnitude = ballSpeed/200 shakeMagnitude = ballSpeed/200
else else
@@ -876,126 +813,6 @@ end
end end
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 if ball[i].y <= 0 then
soundtype = love.math.random(1, 5) soundtype = love.math.random(1, 5)
sounds['wallhit']:setPitch(ballSpeed/250) sounds['wallhit']:setPitch(ballSpeed/250)
@@ -1509,7 +1326,7 @@ function love.draw()
player1:render() player1:render()
player2:render() player2:render()
elseif gameState == 'animation' then 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 else
mapChanger() mapChanger()
if t < shakeDuration then if t < shakeDuration then
@@ -1531,6 +1348,7 @@ function love.draw()
love.graphics.setShader() love.graphics.setShader()
love.graphics.clear(40/255, 40/255, 40/255, 1) --BACKGROUND COLOR love.graphics.clear(40/255, 40/255, 40/255, 1) --BACKGROUND COLOR
end end
staticanimator()
if (gameMode == 'practice') then if (gameMode == 'practice') then
love.graphics.rectangle('fill', VIRTUAL_WIDTH, 0, 10, VIRTUAL_HEIGHT) love.graphics.rectangle('fill', VIRTUAL_WIDTH, 0, 10, VIRTUAL_HEIGHT)
end end
@@ -1544,7 +1362,7 @@ function love.draw()
if gameState == 'play' or gameState == '1serve' or gameState == '2serve' then if gameState == 'play' or gameState == '1serve' or gameState == '2serve' then
love.graphics.setFont(smallfont) love.graphics.setFont(smallfont)
end end
love.graphics.setColor(1,1,1,1)
love.graphics.printf(TEXT,0,20,VIRTUAL_WIDTH,'center') love.graphics.printf(TEXT,0,20,VIRTUAL_WIDTH,'center')
love.graphics.setFont(smallfont) love.graphics.setFont(smallfont)
love.graphics.printf(updateTEXT,0,VIRTUAL_HEIGHT * 0.95,VIRTUAL_WIDTH,'left') 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) love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
end end
end end
if gameState ~= 'assign' then if gameState ~= 'assign' then
player1:render() player1:render()
player3:render() player3:render()


Loading…
Cancel
Save