From 0d843207bc6fe33542c52596158779ae117c3e5d Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Sun, 24 Apr 2016 16:56:06 -0700 Subject: Added antivirus laser charge you have to wait for it to charge before you can fire it --- assets.lua | 3 ++- assets/antivirus_charge.png | Bin 0 -> 655 bytes var.lua | 2 +- virus1.lua | 20 ++++++++++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 assets/antivirus_charge.png diff --git a/assets.lua b/assets.lua index d5fbc3c..5e32b17 100644 --- a/assets.lua +++ b/assets.lua @@ -90,7 +90,8 @@ function loadAssets() opengun = love.audio.newSource("assets/antivirus_open_gun.ogg"), laser = love.audio.newSource("assets/antivirus_laser.ogg"), bullet = love.graphics.newImage("assets/bullet_blue.png"), - hit = love.audio.newSource("assets/antivirus_hit.ogg") + hit = love.audio.newSource("assets/antivirus_hit.ogg"), + charge = love.graphics.newImage("assets/antivirus_charge.png") } notification = { bubble = love.graphics.newImage("assets/notification.png"), diff --git a/assets/antivirus_charge.png b/assets/antivirus_charge.png new file mode 100644 index 0000000..076c21f Binary files /dev/null and b/assets/antivirus_charge.png differ diff --git a/var.lua b/var.lua index 0ddfa72..fad339a 100644 --- a/var.lua +++ b/var.lua @@ -97,7 +97,7 @@ function loadVar() av.wings = 0 av.gun = 0 av.transform = false - av.charge = 0 + av.charge = 40 av.fireb = false av.fire = false av.bullets = {} diff --git a/virus1.lua b/virus1.lua index 1eb524d..76294c9 100644 --- a/virus1.lua +++ b/virus1.lua @@ -57,6 +57,11 @@ function drawVirusFight1() love.graphics.setColor(colors.font.dark) love.graphics.print("FIRE", win[4].x+138/2+76, win[4].y+99) love.graphics.setColor(256,256,256) + drawDownBox(win[4].x+138/2+79-1, win[4].y+40-1, 42, 42, 2) + love.graphics.stencil(chargeStencil, "replace", 1) + love.graphics.setStencilTest("greater", 0) + love.graphics.draw(antivirus.charge, win[4].x+138/2+79, win[4].y+40) + love.graphics.setStencilTest() if av.wings == 138/2 then love.graphics.draw(antivirus.left, win[4].x+138/2-av.wings, win[4].y, 0, win[4].s) love.graphics.draw(antivirus.right, win[4].x+138/2+97+av.wings, win[4].y, 0, win[4].s) @@ -72,7 +77,10 @@ function drawVirusFight1() if av.wings == 138/2 and av.gun ~= 98 then av.gun = av.gun + 1 end - if (sys.mouse.p.x >= win[4].x+138/2+71 and sys.mouse.p.x <= (win[4].x+138/2+71)+56 and av.fireb == true + if av.charge ~= 40 then + av.fireb = false + end + if (sys.mouse.p.x >= win[4].x+138/2+71 and sys.mouse.p.x <= (win[4].x+138/2+71)+56 and av.fireb == true and av.charge == 40 and sys.mouse.p.y >= win[4].y+93 and sys.mouse.p.y <= (win[4].y+93)+19 and sys.mouse.drag == false and sys.mouse.p.p == true) then av.fire = true av.fireb = false @@ -82,9 +90,14 @@ function drawVirusFight1() v1.c.chat.char = 0 end end - if v1.c.chat.msgs == 15 or v1.c.chat.msgs == 17 or v1.c.chat.msgs == 19 or v1.c.chat.msgs == 21 then + if (v1.c.chat.msgs == 15 or v1.c.chat.msgs == 17 or v1.c.chat.msgs == 19 or v1.c.chat.msgs == 21) and av.charge == 40 then av.fireb = true end + if av.charge < 40 then + av.charge = av.charge + math.random(1,10,25,40,5,2,8)*delta + elseif av.charge > 40 then + av.charge = 40 + end if av.fire == true then addBullet(win[4].x+138/2+99,win[4].y+5-av.gun,math.rad(-90),25,"av") antivirus.laser:play() @@ -314,3 +327,6 @@ function drawBullets() end end end +function chargeStencil() + love.graphics.rectangle("fill", win[4].x+138/2+79, win[4].y+40+40, 40, -av.charge) +end -- cgit