summaryrefslogtreecommitdiffhomepage
path: root/not/Hero.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-03-19 00:21:02 +0100
committerAki <nthirtyone@gmail.com>2017-03-19 00:21:02 +0100
commit340a3a4b92de5495b47e8e1e102178edfd97514f (patch)
tree62e528b45c90affd4339942a8911fe51137ad963 /not/Hero.lua
parentc16c1206f5884614157b8f5049e601ff77478d7f (diff)
downloadroflnauts-340a3a4b92de5495b47e8e1e102178edfd97514f.zip
roflnauts-340a3a4b92de5495b47e8e1e102178edfd97514f.tar.gz
roflnauts-340a3a4b92de5495b47e8e1e102178edfd97514f.tar.bz2
Night commit, added PhysicalBody, newImage to sprite
Diffstat (limited to 'not/Hero.lua')
-rw-r--r--not/Hero.lua19
1 files changed, 8 insertions, 11 deletions
diff --git a/not/Hero.lua b/not/Hero.lua
index 7ddc724..8d226ac 100644
--- a/not/Hero.lua
+++ b/not/Hero.lua
@@ -1,12 +1,6 @@
--- `Hero`
--- Entity controlled by a player. It has a physical body and a sprite. Can play animations and interact with other instances of the same class.
+--- `Hero`
+-- Hero (naut) entity that exists in a game world.
-- Collision category: [2]
-
--- WHOLE CODE HAS FLAG OF "need a cleanup"
-require "not.Sprite"
-
--- Metatable of `Hero`
--- nils initialized in constructor
Hero = {
-- General and physics
name = "empty",
@@ -44,10 +38,13 @@ Hero = {
-- Animations table
animations = require "animations"
}
+
+-- `Hero` is a child of `PhysicalBody`.
+require "not.PhysicalBody"
Hero.__index = Hero
-setmetatable(Hero, Sprite)
+setmetatable(Hero, PhysicalBody)
--- Constructor of `Hero`
+-- Constructor of `Hero`.
function Hero:new (game, world, x, y, name)
-- Meta
local o = {}
@@ -64,7 +61,7 @@ function Hero:new (game, world, x, y, name)
o.body:setFixedRotation(true)
-- Misc
o.name = name or "empty"
- o:setImage(newImage("assets/nauts/"..o.name..".png"))
+ o:setImage(Sprite.newImage("assets/nauts/"..o.name..".png"))
o.world = game
o.punchcd = 0
-- Animation