From 340a3a4b92de5495b47e8e1e102178edfd97514f Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 19 Mar 2017 00:21:02 +0100 Subject: Night commit, added PhysicalBody, newImage to sprite --- not/Hero.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'not/Hero.lua') 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 -- cgit v1.1