• Create Account

### #ActualArthur Souza

Posted 14 October 2012 - 11:47 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls.

I made a function to which I can just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.
This is similar to the spritesheet technique or the tileset technique, in which a single image contains several textures, and you draw a section of the image at a time.

Don't know if youre using XNA, but I believe that in whatever you're using, you can select which section of the texture you're going to draw.

Some C#ish pseudocode

void DrawRectangle(Rectangle area, int borderSize)
{
// Rect constructor = Rectangle(x, y, width, height)
// borders
// top left

draw(
texture,
new Rectangle(area.X, area.Y, borderSize, borderSize, // where is this going to be drawn
new Rectangle(0, 0, borderSize, borderSize)); // section of the image to be drawn
// bottom left
batch.Draw(
texture,
new Rectangle(area.X, (area.Y + area.Height - borderSize), borderSize, borderSize),
// top right
batch.Draw(
texture,
new Rectangle(area.X + area.Width - borderSize, area.Y, borderSize, borderSize),
new Rectangle((texture.Width -  borderSize), 0, borderSize, borderSize));
// bottom right
batch.Draw(
texture,
new Rectangle(area.X + area.Width - borderSize, area.Y + area.Height - borderSize, borderSize, borderSize),
new Rectangle(texture.Width - borderSize, texture.Height - borderSize, borderSize, borderSize));
}


### #5Arthur Souza

Posted 14 October 2012 - 11:45 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls.

I made a function to which I can just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.

This is similar to the spritesheet technique or the tileset technique, in which a single image contains several textures, and you draw a section of the image at a time.

Don't know if youre using XNA, but I believe that in whatever you're using, you can select which section of the texture you're going to draw.

### #4Arthur Souza

Posted 14 October 2012 - 11:44 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls.

I made a function to which I can just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.

Don't know if youre using XNA, but I believe that in whatever you're using, you can select which section of the texture you're going to draw.

### #3Arthur Souza

Posted 14 October 2012 - 11:44 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls.

I made a function to which I can just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.

### #2Arthur Souza

Posted 14 October 2012 - 11:40 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls.

I made a function to which I can just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.

### #1Arthur Souza

Posted 14 October 2012 - 11:39 PM

On my engine, using XNA, I use an image of the entire square, with corners and walls, and just pass the size of the rectangle I want to draw to a function, and the function will draw the sections of the image, according to the rectangle size.

PARTNERS