Another feature you can't see here is that when you have tiles selected and you move the mouse over the drawing area you will get a semi transparent preview of the object you are about to draw so that you can see what it looks like before you draw to the object.
Objects can be saved and loaded correctly (although I have not implemented loading properly yet, but I have tested it to make sure it doesn't blow up). Better still I've also made optimizations to the tileset manager so that saved files do not take up as much space. The optimization also means that when you load a tileset, the file is copied in the programs directory so that it doesn't have to keep looking for where the file is hidden on your computer. Thinking ahead, it also makes it easier for me to load resources once I begin working on the game itself.
Other features that have been implemented allow you to resize the size of the object (i.e how much space you have to draw stuff), the ability to snap your tile placements to a grid, as well as the ability to toggle grid drawing, tile placement previews and the snap to grid function on/off.
I'll begin working on a browser for all saved objects soon so that we can begin making maps!
Also as promised the solution to the puzzle from my last post:
You can work out the number of tiles that go across the tileset easy enough by doing
Tiles Across = Tileset Width / Single Tile Width
We can also find the row and column of the first tile ID that is selected
First Tile Column = X Position of Selected Tiles / Single Tile Width
First Tile Row = Y Position of Selected Tiles / Single Tile Height
From which we can get the ID of the first selected tile
First Tile ID = (First Tile Row * Tiles Across) + First Tile Column
Now all we need is the total number of tiles selected down and across
Selected Tiles Across = Width of Selection Box / Single Tile Width
Selected Tiles Down = Height of Selection Box / Single Tile Height
Now we have to use for loops to make numbers increment every time we run this next equation.
ID = (First Tile ID + Incrementing Number 1) + (Tiles Across * Incrementing Number 2)
Incrementing Number 1 is constantly incremented, until it is equal to the number of Selected Tiles Across at which point it is reset to 0.
Incrementing Number 2 remains at 0 until Incrementing Number 1 is reset. When this happens Incrementing Number 2 is incremented.
The process is repeated until Incrementing Number 2 is equal to the number of Selected Tiles Down
For any programmers looking for the solution here it is in C#
int TilesAcross = (m_Texture.Width / m_TileWidth);
int FirstTileColumn = (m_SelectedTile.X / m_TileWidth);
int FirstTileRow = (m_SelectedTile.Y / m_TileHeight);
int FirstTileID = (FirstTileRow * TilesAcross) + FirstTileColumn;
int SelectedTilesAcross = m_SelectedTile.Width / m_TileWidth;
int SelectedTilesDown = m_SelectedTile.Height / m_TileHeight;
List
for (int y = 0; y < SelectedTilesDown; y++)
{
for (int x = 0; x < SelectedTilesAcross; x++)
{
int i = (FirstTileID + x) + (TilesAcross * y);
list.Add(i);
}
}
return list;
No comments:
Post a Comment