summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-07-16 22:10:07 +0200
committerAki <nthirtyone@gmail.com>2017-07-16 22:10:07 +0200
commit0c70843b512c0e1633f77f5b0355cf5c2f80efe5 (patch)
treee89db815aef1f6817c136c50f912ae1b8bf6a468
parentb2c2ef1ae1300a2a2610525bf19db227d6d5e54b (diff)
downloadroflnauts-0c70843b512c0e1633f77f5b0355cf5c2f80efe5.zip
roflnauts-0c70843b512c0e1633f77f5b0355cf5c2f80efe5.tar.gz
roflnauts-0c70843b512c0e1633f77f5b0355cf5c2f80efe5.tar.bz2
Initial trial effect, it's too fun
-rw-r--r--not/Effect.lua8
-rw-r--r--not/Hero.lua28
2 files changed, 20 insertions, 16 deletions
diff --git a/not/Effect.lua b/not/Effect.lua
index 82d6819..6c0dad0 100644
--- a/not/Effect.lua
+++ b/not/Effect.lua
@@ -1,11 +1,6 @@
-require "not.Decoration"
-
--- `Effect`
-- Short animation with graphics that plays in various situation.
--- TODO: animation is currently slower than it used to be, check if it is ok; if not then make it possible to change it to 0.06 delay.
-Effect = Decoration:extends()
-
-Effect.finished = false
+Effect = require "not.Decoration":extends()
-- Constructor of `Effect`.
function Effect:new (name, x, y, world)
@@ -14,6 +9,7 @@ function Effect:new (name, x, y, world)
Effect:setImage(Sprite.newImage("assets/effects.png"))
end
Effect.__super.new(self, x, y, world, nil)
+ self.finished = false
self:setAnimationsList(require("config.animations.effects"))
self:setAnimation(name)
end
diff --git a/not/Hero.lua b/not/Hero.lua
index cb205bf..0406e51 100644
--- a/not/Hero.lua
+++ b/not/Hero.lua
@@ -1,9 +1,7 @@
-require "not.PhysicalBody"
-
--- `Hero`
-- Hero (often referred to as: "naut") entity that exists in a game world.
-- Collision category: [2]
-Hero = PhysicalBody:extends()
+Hero = require "not.PhysicalBody":extends()
Hero.name = "empty"
Hero.angle = 0
@@ -114,6 +112,12 @@ function Hero:update (dt)
self:respawn()
end
+ -- Trail spawner
+ if self.combo > 100 then
+ local dx, dy = love.math.random(-4, 4), love.math.random(-4, 4)
+ self:createEffect("trail", dx, dy)
+ end
+
-- # PUNCH
-- Cooldown
self.punchCooldown = self.punchCooldown - dt
@@ -188,14 +192,18 @@ function Hero:goToNextFrame ()
end
-- Spawn `Effect` relative to `Hero`
-function Hero:createEffect (name)
- if name == "trail" or name == "hit" then
- -- 16px effect: -7 -7
- self.world:createEffect(name, self.body:getX()-8, self.body:getY()-8)
- elseif name ~= nil then
- -- 24px effect: -12 -15
- self.world:createEffect(name, self.body:getX()-12, self.body:getY()-15)
+function Hero:createEffect (name, dx, dy)
+ local x, y = self.body:getX()-8, self.body:getY()-8 -- 16px effect: -7 -7
+ if not (name == "trail") and not (name == "hit") then
+ x, y = x-4, y-7 -- 24px effect: -12 -15
+ end
+ if dx then
+ x = x + dx
+ end
+ if dy then
+ y = y + dy
end
+ self.world:createEffect(name, x, y)
end
-- Creates temporary fixture for hero's body that acts as sensor.