summaryrefslogtreecommitdiffhomepage
path: root/cloud.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
committerAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
commit0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (patch)
tree8d270eb07f589d2487b3ce66d4865e5a4718042a /cloud.lua
parent55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff)
parenta03c1125f10fbbad253a0efc4727072fcbd55345 (diff)
downloadroflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2
Merge branch 'com'
Diffstat (limited to 'cloud.lua')
-rw-r--r--cloud.lua63
1 files changed, 0 insertions, 63 deletions
diff --git a/cloud.lua b/cloud.lua
deleted file mode 100644
index c12e236..0000000
--- a/cloud.lua
+++ /dev/null
@@ -1,63 +0,0 @@
--- `Cloud`
--- That white thing moving in the background.
-
--- 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 = nil,
- quads = {
- [1] = love.graphics.newQuad( 1, 1, 158,47, 478,49),
- [2] = love.graphics.newQuad(160, 1, 158,47, 478,49),
- [3] = love.graphics.newQuad(319, 1, 158,47, 478,49)
- }
-}
-
--- Constructor of `Cloud`
-function Cloud:new(x, y, t, v)
- -- Meta
- local o = {}
- setmetatable(o, self)
- self.__index = self
- -- 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
- o.y = y or self.y
- o.t = t or self.t
- o.v = v or self.v
- return o
-end
-
--- Position
-function Cloud:getPosition()
- return self.x, self.y
-end
-
--- Update of `Cloud`, returns x for world to delete cloud after reaching right corner
-function Cloud:update(dt)
- self.x = self.x + self.v*dt
- return self.x
-end
-
--- Draw `Cloud`
-function Cloud:draw(offset_x, offset_y, scale)
- -- locals
- local offset_x = offset_x or 0
- local offset_y = offset_y or 0
- local scale = scale or 1
- local x, y = self:getPosition()
- -- pixel grid
- local draw_x = (math.floor(x) + offset_x) * scale
- local draw_y = (math.floor(y) + offset_y) * scale
- -- draw
- love.graphics.setColor(255,255,255,255)
- love.graphics.draw(self.sprite, self.quads[self.t], draw_x, draw_y, 0, scale, scale)
-end \ No newline at end of file