examples: add a test for entities
This commit is contained in:
parent
3fce24a211
commit
3e2e29539b
3 changed files with 37 additions and 0 deletions
8
examples/test_scene2/actors/explosion.lua
Normal file
8
examples/test_scene2/actors/explosion.lua
Normal file
|
@ -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
|
17
examples/test_scene2/actors/parent.lua
Normal file
17
examples/test_scene2/actors/parent.lua
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue