From 54167f8a7792c7f6b27e179e4b4595e3759c8257 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 20 Jul 2019 17:46:40 +0200 Subject: [PATCH] feat(action3D): add coin actor --- examples/gameplay/action3D/actors/coin.lua | 14 ++++++++++++++ examples/gameplay/action3D/actors/init.lua | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 examples/gameplay/action3D/actors/coin.lua diff --git a/examples/gameplay/action3D/actors/coin.lua b/examples/gameplay/action3D/actors/coin.lua new file mode 100644 index 0000000..c543b82 --- /dev/null +++ b/examples/gameplay/action3D/actors/coin.lua @@ -0,0 +1,14 @@ +local Base = require "gamecore.modules.world.actors.actor3D" +local Coin = Base:extend() + +function Coin:new(world, x, y, z) + Coin.super.new(self, world, "coin", x, y, z + 16, 16, 16, 16, false) + self:setSprite("coin") +end + +function Coin:takeCoin(other) + self.obj.GFX(self.world, self.x + 8, self.y + 8, self.z + 8, "sparkle") + self:destroy( ) +end + +return Coin diff --git a/examples/gameplay/action3D/actors/init.lua b/examples/gameplay/action3D/actors/init.lua index 78d243c..1f594b5 100644 --- a/examples/gameplay/action3D/actors/init.lua +++ b/examples/gameplay/action3D/actors/init.lua @@ -4,10 +4,13 @@ local Obj = {} local cwd = (...):gsub('%.init$', '') .. "." Obj.Player = require(cwd .. "player") Obj.Box = require(cwd .. "box") +Obj.Coin = require(cwd .. "coin") +Obj.GFX = require("gamecore.modules.world.actors.gfx3D") Obj.index = {} Obj.index["player"] = Obj.Player Obj.index["box"] = Obj.Box +Obj.index["coin"] = Obj.Coin Obj.collisions = {} Obj.collisions["wall"] = require(cwd .. "wall")