summaryrefslogtreecommitdiffhomepage
path: root/not/Platform.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 /not/Platform.lua
parent55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff)
parenta03c1125f10fbbad253a0efc4727072fcbd55345 (diff)
downloadroflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2
Merge branch 'com'
Diffstat (limited to 'not/Platform.lua')
-rw-r--r--not/Platform.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/not/Platform.lua b/not/Platform.lua
new file mode 100644
index 0000000..3748c47
--- /dev/null
+++ b/not/Platform.lua
@@ -0,0 +1,37 @@
+--- `Platform`
+-- Static platform physical object with a sprite. `Players` can walk on it.
+-- Collision category: [1]
+-- TODO: reformat code to follow new code patterns
+-- TODO: comment uncovered code parts
+Platform = {
+ world = --[[not.World]]nil,
+}
+
+-- `Platform` is a child of `PhysicalBody`.
+require "not.PhysicalBody"
+Platform.__index = Platform
+setmetatable(Platform, PhysicalBody)
+
+-- Constructor of `Platform`
+function Platform:new (animations, shape, game, x, y, sprite)
+ local o = setmetatable({}, self)
+ o:init(animations, shape, game, x, y, sprite)
+ return o
+end
+
+-- Initializer of `Platform`.
+function Platform:init (animations, shape, world, x, y, imagePath)
+ PhysicalBody.init(self, world, x, y, imagePath)
+ self:setAnimationsList(animations)
+ self.world = world
+ -- Create table of shapes if single shape is passed.
+ if type(shape[1]) == "number" then
+ shape = {shape}
+ end
+ -- Add all shapes from as fixtures to body.
+ for _,single in pairs(shape) do
+ local fixture = self:addFixture(single)
+ fixture:setCategory(1)
+ fixture:setFriction(0.2)
+ end
+end \ No newline at end of file