Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a shooter, it's still very early, but i'm implementing some polygon hitboxes.

So far i have created a polygon class, and i'm looking into how i can hook it onto my player.

I'm trying to stay away from having a Tick() function in my polygon class, and I would rather not update the position every tick (it would clutter up my tick functions). At the same time I would really like to have the positions in there somehow (it has a drawing function, and i will be using it for hit detection)

How would i go about implementing this polygon object into my entities?

share|improve this question
up vote 3 down vote accepted

This seems like a good place to use Composition.

Give the Entity your Polygon class as a property and update it whenever the entity moves.

public class Entity {
    public Polygon Hitbox { get; private set; }

    public void Move() {
        // stuff to move player
        this.Hitbox.X = this.Position.X;
        this.Hitbox.Width = ...
share|improve this answer
ofcourse! i just need to add a move method to my player! that would solve my problem of it cluttering my tick method, thanks! – Delusional Logic Oct 23 '12 at 22:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.