I wanted a tip, a guidance perhaps to know the best way to draw a tile all over the screen. This tile is a 16x16 tile that should be the floor in my top-down map. I set my resolution to 1280x720 and i know i should make a foreach and a for loop ( i looked around in the foruns to find this) but couldn’t make it work on my own. I just finished a monogame course and i’m trying to make a game on my own to really acknowledge the things i’ve learned, but i wanted a help with it if anyone could. I wanted to do the same thing to draw things repetitively on the screen (like trees, rocks, and this kind of stuff). My tile is called “floor”, it’s imported alright and it is loaded too with backGroundFloor = Content.Load<Texture2D>("background/floor");

Anyone know a way to solve this? Also, would this be the best way to do it, or should i just draw a full map and place it on screen? I think this way would be more complicated with itens on the screen to handle collisions and etc


1 Answer 1


The tile is 16x16, so calculate the number of tiles required for the width:

1280 / 16 = 80 720 / 16 = 45

So 80 wide by 45 tall:

This means that you need to draw 80 * 45 = 3600 instances to the screen in the Draw() method:

for (int i = 0; i < 3600; i++)
   _spriteBatch.Draw(backGroundFloor, new Vector2(i % 80 * 16, i / 80 * 16), Color.White);

Make sure that this line is higher(first) than the other Draw statements or loops so that it remains in the background.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .