Page 1 of 1

Awesome Idea! Debug your games

PostPosted: Thu Apr 22, 2010 9:02 pm
by Hblade
I have an idea :D...





Debug your sprites collision using a canvas!

To do this, Your canvas x must be equal to your views, as well as it's width and height. This is untested seeing as how I'm doing this on my new wii. Anyways, yeah after you did that, you must get the Xscreen and Yscreen of your actor, (someone correct me if I'm wrong on the code I cant test it :P)
Code: Select all
drawRect(char *ActorName)
{
    *Actor n = ActorName // I think :D
    int actorX = n->x;
    int actorY = n->y;
    int actorWidth = n->width;
    int actorHeight = n->height;
    setpen(255, 0, 0, 0, 1); //Set pen to red
    moveto(actorX, actorY);
    lineto(actorX, actorY+actorHeight);
    lineto(actorX+actorWidth, actorY+actorHeight);
    lineto(actorX+actorWidth, actorY);
    lineto(actorX, actorY);
}

Uh, if there's anything I left out lemme know but that should draw a square around the actor you named. if it doesn't lemme know :D.

This can be usefull for collision as it lets you see the real width and height of your sprite :D.

This will not work for tiles, but hopefully it works well :) This can be used many times so you can draw a square on more then just 1 actor but with one canvas hopefully :D

Thanks :3