Search code examples
design-patternsgame-physics

What is the optimized design methodology for a directed entity?


I mean I want to have some directed objects in my game, like a laser beam or a rocket facing somewhere.

How would you store these objects for collisions? (consider them like a circular shape to make thing easier)


My hypothesis' are:

-Either store two coordinate vectors

-Or Store a coordinate vector and an angle


Each have their advantages and drawbacks: -Storing more data would mean more load in memory -Storing less data would mean more load in calculations

I just don't know which would lead to a more optimized way, which is more generally acceptable?

Thank you for the feedback!


Solution

  • From my experience two coordinate vectors is better.

    And if you query and need angle a lot you can store angle also.

    Also from my experience, for games speed is more important than memory

    premature optimization is the root of all evil http://c2.com/cgi/wiki?PrematureOptimization