Gornova/MarteEngine

Duplicate debugging code

Closed this issue · 2 comments

The debug rectangle is rendered 2 times:
In World @ https://github.com/Gornova/MarteEngine/blob/master/src/it/marteEngine/World.java#L137
In Entity @ https://github.com/Gornova/MarteEngine/blob/master/src/it/marteEngine/entity/Entity.java#L246

        g.setColor(ME.borderColor);
        Rectangle hitBox = new Rectangle(e.x + e.hitboxOffsetX, e.y
                + e.hitboxOffsetY, e.hitboxWidth, e.hitboxHeight);
        g.draw(hitBox);
        g.setColor(Color.white);

Maybe debugging code should be in 1 place. A DebugEntity extends Entity maybe this class would wrap a normal Entity. This DebugEntity would then render all debug information and at the start of the render method do super.render. Keeps Entity cleaner...

Also we could create the rectangle once and then reuse that rectangle. If the hitbox changes we create a new Hitbox rectangle.

I don't remember why I've made this, maybe some special case?

I created a renderDebug method in entity, and world calls it, should always work.