summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cloud.lua11
-rw-r--r--effect.lua12
2 files changed, 10 insertions, 13 deletions
diff --git a/cloud.lua b/cloud.lua
index 2e17976..30cb849 100644
--- a/cloud.lua
+++ b/cloud.lua
@@ -4,12 +4,13 @@
-- WHOLE CODE HAS FLAG OF "need a cleanup"
-- Metatable of `Cloud`
+-- nils initialized in constructor
Cloud = {
x = 0, -- position horizontal
y = 0, -- position vertical
t = 1, -- type (sprite number)
v = 13, -- velocity
- sprite = love.graphics.newImage("assets/clouds.png"),
+ sprite = nil,
quads = {
[1] = love.graphics.newQuad( 1, 1, 158,47, 478,49),
[2] = love.graphics.newQuad(160, 1, 158,47, 478,49),
@@ -23,11 +24,9 @@ function Cloud:new(x, y, t, v)
local o = {}
setmetatable(o, self)
self.__index = self
- -- Set filter
- local min, mag = self.sprite:getFilter()
- if min ~= "nearest" or
- mag ~= "nearest" then
- self.sprite:setFilter("nearest", "nearest")
+ -- Load spritesheet to metatable if not yet loaded
+ if self.sprite == nil then
+ self.sprite = love.graphics.newImage("assets/clouds.png")
end
-- Init
o.x = x or self.x
diff --git a/effect.lua b/effect.lua
index 1a0b3f8..31d20a4 100644
--- a/effect.lua
+++ b/effect.lua
@@ -6,11 +6,11 @@
Effect = {
x = 0,
y = 0,
- delay = 0.08,
+ delay = 0.06,
initial = nil,
frame = 1,
animation = nil,
- sprite = love.graphics.newImage("assets/effects.png"),
+ sprite = nil,
quads = require "effects"
}
@@ -20,11 +20,9 @@ function Effect:new(name, x, y)
local o = {}
setmetatable(o, self)
self.__index = self
- -- Set filter
- local min, mag = self.sprite:getFilter()
- if min ~= "nearest" or
- mag ~= "nearest" then
- self.sprite:setFilter("nearest", "nearest")
+ -- Load spritesheet to metatable if not yet loaded
+ if self.sprite == nil then
+ self.sprite = love.graphics.newImage("assets/effects.png")
end
-- Init
o.initial = o.delay