mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-22 07:56:52 -06:00
First demo commit.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
local AISystem = tiny.processingSystem(class "AISystem")
|
||||
|
||||
function AISystem:init(target)
|
||||
self.target = target
|
||||
end
|
||||
|
||||
AISystem.filter = tiny.requireAll("ai", "pos", "platforming")
|
||||
|
||||
function AISystem:process(e, dt)
|
||||
if not self.target then
|
||||
return
|
||||
end
|
||||
local targetx = self.target.pos.x
|
||||
local pos = e.pos
|
||||
local p = e.platforming
|
||||
p.moving = self.target.isAlive
|
||||
if targetx > pos.x then
|
||||
p.direction = 'r'
|
||||
end
|
||||
if targetx < pos.x then
|
||||
p.direction = 'l'
|
||||
end
|
||||
p.jumping = math.random() < 0.5 * dt
|
||||
end
|
||||
|
||||
return AISystem
|
||||
Reference in New Issue
Block a user