diff --git a/examples/test_scene2/actors/explosion.lua b/examples/test_scene2/actors/explosion.lua new file mode 100644 index 0000000..8a9ef42 --- /dev/null +++ b/examples/test_scene2/actors/explosion.lua @@ -0,0 +1,8 @@ +local Parent = require "examples.test_scene2.actors.parent" +local Explosion = Parent:extend() + +function Explosion:new(scene, x, y) + Explosion.super.new(self, scene, "explosion", x - 8, y - 8, 16, 16) +end + +return Explosion diff --git a/examples/test_scene2/actors/parent.lua b/examples/test_scene2/actors/parent.lua new file mode 100644 index 0000000..fc61074 --- /dev/null +++ b/examples/test_scene2/actors/parent.lua @@ -0,0 +1,17 @@ +local Base = require "gamecore.modules.world.actors.actor2D" +local Parent = Base:extend() + +function Parent:new(scene, type, x, y, w, h) + self.scene = scene + Parent.super.new(self, scene.world, type, x, y, w, h) +end + +function Parent:update(dt) + +end + +function Parent:draw() + love.graphics.rectangle("fill", self.x, self.y, self.w, self.h) +end + +return Parent diff --git a/examples/test_scene2/init.lua b/examples/test_scene2/init.lua index 4f08301..93ca324 100644 --- a/examples/test_scene2/init.lua +++ b/examples/test_scene2/init.lua @@ -26,6 +26,9 @@ local TestScene = Scene:extend() local folder = "examples/test_scene2/" +local World = require "gamecore.modules.world.baseworld" +local Explosion = require "examples.test_scene2.actors.explosion" + function TestScene:new() TestScene.super.new(self) @@ -35,6 +38,11 @@ function TestScene:new() self.i = 0 self.estImpair = false + + self.world = World(self) + Explosion(self, 12, 12) + Explosion(self, 1, 78) + Explosion(self, 40, 200) end function TestScene:update(dt) @@ -43,6 +51,8 @@ function TestScene:update(dt) local i = math.floor(self.i) self.estImpair = (math.floor(i / 2) ~= (i / 2)) + + self.world:update(dt) end function TestScene:mousepressed(x, y) @@ -69,6 +79,8 @@ function TestScene:draw() utils.graphics.resetColor() end + + self.world:draw() end return TestScene