I want to implement an entity component system, but I've been some trouble as of late. Let's say that I have a fire ball spell that spawns a ball of fire which moves towards a random enemy in 500 units range. In an OO architecture, I would have a Player class and I could simply detect a keypress and cast the spell like so:
function player:update(dt)
if is_key_pressed('e') then
self:cast_fire_ball()
end
endand the cast fireball spell implementation would be something close to this:
function Player:cast_fire_ball()
-- query the world for nearby units, filter …