diff options
author | Aki <nthirtyone@gmail.com> | 2017-05-26 22:44:00 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-05-26 22:44:00 +0200 |
commit | b14d4608dc921f882067c43c71fcf04db7b2f794 (patch) | |
tree | 04c00f9dde638f0a1689f601f780975fdd158b24 /not/Cloud.lua | |
parent | 81e72006a4ca0578f0bbc31d0788a6e0223fdb63 (diff) | |
download | roflnauts-b14d4608dc921f882067c43c71fcf04db7b2f794.zip roflnauts-b14d4608dc921f882067c43c71fcf04db7b2f794.tar.gz roflnauts-b14d4608dc921f882067c43c71fcf04db7b2f794.tar.bz2 |
Rest of entities moved to new oop module; tested
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 |