summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-14 16:55:40 +0200
committerAki <nthirtyone@gmail.com>2016-05-14 16:55:40 +0200
commit25701ee54e8fbdcfd3a66fd1605f5b5b647e78a2 (patch)
tree766e16e67e8e83ac435ea7cb22c66559d0a9b5f7
parent20ed15b3a008fcc4f90c2bd32cc2e36e49072554 (diff)
downloadroflnauts-25701ee54e8fbdcfd3a66fd1605f5b5b647e78a2.zip
roflnauts-25701ee54e8fbdcfd3a66fd1605f5b5b647e78a2.tar.gz
roflnauts-25701ee54e8fbdcfd3a66fd1605f5b5b647e78a2.tar.bz2
Sometimes I just hate desktop github
-rw-r--r--cloud.lua2
-rw-r--r--main.lua2
-rw-r--r--world.lua54
3 files changed, 56 insertions, 2 deletions
diff --git a/cloud.lua b/cloud.lua
index d825eda..bb48eb6 100644
--- a/cloud.lua
+++ b/cloud.lua
@@ -1,5 +1,5 @@
-- `Cloud`
--- That white thing moving in the background.
+-- That white thing moving in the background.
-- WHOLE CODE HAS FLAG OF "need a cleanup"
diff --git a/main.lua b/main.lua
index 01c46bb..7e3d71e 100644
--- a/main.lua
+++ b/main.lua
@@ -15,7 +15,7 @@ function love.load ()
-- World physics
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.81*64, true)
- world:setCallbacks(beginContact, endContact, preSolve, postSolve)
+ world:setCallbacks(beginContact, endContact)
-- Platforms (`Ground`)
Platforms = {}
diff --git a/world.lua b/world.lua
new file mode 100644
index 0000000..e4301e4
--- /dev/null
+++ b/world.lua
@@ -0,0 +1,54 @@
+-- `World`
+-- Used to manage physical world and everything inside it: clouds, platforms, nauts, background etc.
+
+-- WHOLE CODE HAS FLAG OF "need a cleanup"
+
+-- Metatable of `World`
+-- nils initialized in constructor
+World = {
+ world = nil,
+ nauts = nil,
+ platforms = nil,
+ clouds = nil,
+ camera = nil -- not sure yet? menu will need scaling too
+}
+
+-- Constructor of `World` ZA WARUDO!
+function World:new()
+ -- Meta
+ local o = {}
+ setmetatable(o, self)
+ self.__index = self
+ -- Physical world initialization
+ love.physics.setMeter(64)
+ o.world = love.physics.newWorld(0, 9.81*64, true)
+ o.world:setCallbacks(o.beginContact, o.endContact)
+ -- Empty tables for objects
+ local c = {}
+ o.clouds = c
+ local n = {}
+ o.nauts = n
+ local p = {}
+ o.platforms = {}
+ return o
+end
+
+-- Add new platform to the world
+function World:createPlatform(x, y, polygon, sprite)
+ table.insert(self.platforms, Ground:new(self.world, x, y, polygon, sprite))
+end
+
+-- Add new naut to the world
+function World:createNaut(x, y, sprite)
+ table.insert(self.nauts, Player:new(self.world, x, y, sprite))
+end
+
+-- Add new cloud to the world
+
+-- Update
+-- Keypressed
+-- Keyreleased
+-- Draw
+
+-- beginContact
+-- endContact \ No newline at end of file