239 reputation
27
bio website
location Australia
age 22
visits member for 4 years, 4 months
seen Oct 1 at 1:02

I love writing code and I'm always reading and learning how to improve my craft

  • I started programming when I was 12 producing terrible Visual Basic 6 games.
  • I moved to C++ at 14 and never looked back.
  • I love working in the terminal and trying to find new and interesting ways to get ideas from my brain to the screen as fast as possible.

Sep
24
awarded  Autobiographer
Jul
20
awarded  Nice Answer
Jun
19
awarded  Caucus
Jun
19
awarded  Constituent
Feb
3
revised How can I remove enemies from my ArrayList after they have died?
Fixed grammar
Jan
5
awarded  Yearling
Jan
4
awarded  Commentator
Jan
4
comment How can I remove enemies from my ArrayList after they have died?
@Liosan that's a good point, the swap trick is certainly useful if removing is too slow. I still think you shouldn't bother with that until performance becomes an issue (or if the container naturally supports it) but it's very useful to know about.
Jan
3
revised How can I remove enemies from my ArrayList after they have died?
added 2 characters in body
Jan
3
answered How can I remove enemies from my ArrayList after they have died?
Oct
3
comment Entity System and rendering
@snake5 Ah that makes sense, what about the case where two systems have equal claim to a component, for example a Powerup and Death system, Powerup monitors health for full health in order to give some bonus and Death monitors health in order to execute death logic.
Oct
3
comment Entity System and rendering
@snake5 how do you solve the issue where it's necessary for a system to know about two or more components? Such as a combat system that might monitor enemies health and change their sprite on death.
Oct
3
comment Entity System and rendering
@snake5 You aren't recalculating data every frame, getComponents returns a vector owned by m_manager that is already known and only changes when you add/remove components. It's an advantage when you have a system that wants to use multiple components of the same entity, for example a PhysicsSystem that wants to use PositionComponent and PhysicsComponent. Other systems will probably want the position and by having a PositionComponent you don't have duplicate data. Primarily it solves the problem of how do components communicate.
Oct
3
comment Entity System and rendering
This example is using a system similar to one described in the articles I linked. The basic idea is multiple systems can reference the same components. m_manager.getComponents<RenderComponent>(); is implemented such that it only retrieves from a vector of RenderComponents and as such there is only a minor (single pointer indirection) change in performance with the advantage of allowing multiple systems to access components.
Oct
3
comment Entity System and rendering
@snake5 you are correct on both counts. I typed the code off the top of my head and there were some problems, thanks for pointing them out. I've fixed the affected code to be less slow and to correctly use entity system idioms.
Oct
3
revised Entity System and rendering
deleted 117 characters in body
Oct
3
answered Entity System and rendering
Jul
7
awarded  Teacher
Jul
7
awarded  Editor
Jan
20
comment “The Game Object” - and component-based design
As far as I understand it all entities do not share the same component, each entity can have N component instances attached to them. A System then queries the game for a list of all entities that have component instances they care about attached to them and then does whatever processing on those