diff options
author | Aki <nthirtyone@gmail.com> | 2017-08-13 02:26:55 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-08-13 02:26:55 +0200 |
commit | b1cf14d64a2d3e28683db87190c4b2c7799c259d (patch) | |
tree | e45dac5cc6ce5265e3e3e2c914eb7cc92a820b8b /not/Cloud.lua | |
parent | 0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (diff) | |
parent | ed62b573417bdc85bec616f6016846b02de4c906 (diff) | |
download | roflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.zip roflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.tar.gz roflnauts-b1cf14d64a2d3e28683db87190c4b2c7799c259d.tar.bz2 |
Merge branch 'multi'maps
Diffstat (limited to 'not/Cloud.lua')
-rw-r--r-- | not/Cloud.lua | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/not/Cloud.lua b/not/Cloud.lua index 3bc5377..25169c0 100644 --- a/not/Cloud.lua +++ b/not/Cloud.lua @@ -1,10 +1,11 @@ +require "not.Decoration" + --- `Cloud` -- That white thing moving in the background. -- TODO: extends variables names to be readable. -Cloud = { - t = 1, -- type (sprite number) - v = 13 -- velocity -} +Cloud = Decoration:extends() +Cloud.t = 1 -- type (sprite number) +Cloud.v = 13 -- velocity -- TODO: allow maps to use other quads and sprites for clouds -- TODO: you know this isn't right, don't you? @@ -26,25 +27,12 @@ local animations = { } } --- `Cloud` is a child of `Decoration`. -require "not.Decoration" -Cloud.__index = Cloud -setmetatable(Cloud, Decoration) - -- Constructor of `Cloud`. -function Cloud:new (x, y, t, v) - local o = setmetatable({}, self) - o:init(x, y, t, v) - -- Load spritesheet statically. +function Cloud:new (x, y, t, v, world) if self:getImage() == nil then self:setImage(Sprite.newImage("assets/clouds.png")) end - return o -end - --- Initializer of `Cloud`. -function Cloud:init (x, y, t, v) - Decoration.init(self, x, y, nil) + Cloud.__super.new(self, x, y, world, nil) self:setAnimationsList(animations) self:setVelocity(v) self:setType(t) @@ -65,7 +53,9 @@ end -- Update of `Cloud`, returns x for world to delete cloud after reaching right corner. function Cloud:update (dt) - Decoration.update(self, dt) + Cloud.__super.update(self, dt) self.x = self.x + self.v*dt return self.x end + +return Cloud |