summaryrefslogtreecommitdiffhomepage
path: root/cloud.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-17 20:07:58 +0200
committerAki <nthirtyone@gmail.com>2016-05-17 20:07:58 +0200
commit1ae4804534f7d5bf308d38ae1b29de6e5bf558c4 (patch)
treec250692cfdf8cd2de3a03942999d40959d401072 /cloud.lua
parent4d2c7c76dfd99dd488edcb162fc6e6bd1f08b7ac (diff)
downloadroflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.zip
roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.gz
roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.bz2
Spritesheet in constructor
Diffstat (limited to 'cloud.lua')
-rw-r--r--cloud.lua11
1 files changed, 5 insertions, 6 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