Awesome Idea! Debug your games

Talk about making games.

Awesome Idea! Debug your games

Postby Hblade » Thu Apr 22, 2010 9:02 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest