Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17625

Implementing spell casts in entity component systems ?

$
0
0

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
end

and the cast fireball spell implementation would be something close to this:

function Player:cast_fire_ball()
    -- query the world for nearby units, filter …

Viewing all articles
Browse latest Browse all 17625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>