@zero_5 wrote:
Hello, everyone
I'm relatively new to Monogame and I really have no idea how to solve this issue.
I have a small tileset (3 tiles, 32x32 - green, brown and blue) made with Tiled, for testing. I loaded it into my program and I want to stretch the tiles (from 32x32 to, let's say, 64x64) to learn how to adapt window size to resolution.This is the original code, to place the tiles:
Tile[,] tiles = new Tile[mapWidth, mapHeight]; for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { tiles[i, j] = new Tile(new Vector2(i * 32, j * 32), new Rectangle((int)sourcePos[intIDs[i, j] - 1].X, (int)sourcePos[intIDs[i, j] - 1].Y, 32, 32), tex); } }
To stretch it, I did this:
Tile[,] tiles = new Tile[mapWidth, mapHeight]; for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { tiles[i, j] = new Tile(new Vector2(i * 64, j * 64), new Rectangle((int)sourcePos[intIDs[i, j] - 1].X, (int)sourcePos[intIDs[i, j] - 1].Y, 64, 64), tex); } }
Basically, I put the position of every tile at 64px instead of 32px, and stretched the rectangle to 64px instead of 32px. Vertically, this works perfectly. Horizontally, not so much, getting all messed up.
Original:
Stretched vertically:
Only modifying the position of the tiles on the X axis:
Stretching the width of the rectangle from 32px to 64px:![]()
(Sorry for badly cropped images)
Can someone more experienced offer me some insight? I can't understand what's going wrong.
Thank you
Posts: 4
Participants: 2