summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-09 06:17:37 +0200
committerAki <nthirtyone@gmail.com>2017-09-09 06:17:37 +0200
commitca8dbe135034f7a72b6b40f6dfd7b772bd51cc39 (patch)
tree40debe5020c49290cc05ba15ce136a4e03811018
parent11dcd305ac4bf23f6fc2ddfe878376abaddefcac (diff)
downloadroflnauts-ca8dbe135034f7a72b6b40f6dfd7b772bd51cc39.zip
roflnauts-ca8dbe135034f7a72b6b40f6dfd7b772bd51cc39.tar.gz
roflnauts-ca8dbe135034f7a72b6b40f6dfd7b772bd51cc39.tar.bz2
Started Camera rework
-rw-r--r--not/Camera.lua39
-rw-r--r--not/World.lua4
2 files changed, 17 insertions, 26 deletions
diff --git a/not/Camera.lua b/not/Camera.lua
index 6e07372..79ebd09 100644
--- a/not/Camera.lua
+++ b/not/Camera.lua
@@ -1,29 +1,20 @@
---- `Camera`
--- Used in drawing.
-Camera = {
- x = 0,
- y = 0,
- dest_x = 0,
- dest_y = 0,
- shake = 0,
- timer = 0,
- delay = 0,
- origin_x = 0,
- origin_y = 0,
- shake_x = 0,
- shake_y = 0,
- world = --[[not.World]]nil,
-}
+--- Used in drawing other stuff in places.
+Camera = require "not.Object":extends()
--- Constructor of `Camera`
function Camera:new (world)
- local o = {}
- setmetatable(o, self)
- self.__index = self
- o.world = world
- o:setPosition(o:follow())
- o:setDestination(o:follow())
- return o
+ self.world = world
+ self.x = 0
+ self.y = 0
+ self.dest_y = 0
+ self.dest_x = 0
+ self.timer = 0
+ self.delay = 0
+ self.origin_x = 0
+ self.origin_y = 0
+ self.shake_x = 0
+ self.shake_y = 0
+ self:setPosition(self:follow())
+ self:setDestination(self:follow())
end
-- Drawing offsets
diff --git a/not/World.lua b/not/World.lua
index 7ed5707..c086bd5 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -38,7 +38,7 @@ function World:new (map, nauts)
self:initClouds()
self:spawnNauts(nauts)
- self.camera = Camera:new(self)
+ self.camera = Camera(self)
musicPlayer:setTrack(self.map.theme)
musicPlayer:play()
@@ -212,7 +212,7 @@ function World:update (dt)
for key,entity in pairs(self.entities) do
if entity:update(dt) then
- table.remove(self.entities, key)
+ table.remove(self.entities, key):delete()
end
end