I see you used monogame extended, or some such… Is this your first code, or is your installation of visual stufio, monogame, etc, confirmed working?
… Now I don’t know extended, and thus not the Map class, but does it need to load some content? You are drawing but not loading content, as far as I can see… Don’t know if that is intentional, depending on what Map does… But yeah. Are you supposed to be loading content somewhere, ie pictures?
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using System;
using System.Collections.Generic;
using System.Text;
namespace rpg
{
class Map
{
private int tileWidth;
private int tileHeight;
private int width;
private int height;
public Map(int pTileWidth, int pTileHeight, int pWidth, int pHeight)
{
tileWidth = pTileWidth;
tileHeight = pTileHeight;
width = pWidth;
height = pHeight;
}
public void draw(SpriteBatch spriteBatch)
{
Vector2 tilePosition = Vector2.Zero;
spriteBatch.Begin();
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
spriteBatch.FillRectangle(tilePosition, new Size2(tileWidth, tileHeight), Color.Black);
}
}
spriteBatch.End();
}
}
ok, can you set a break-point inside the map class draw method, to see if your execution reaches into it at all, or it crashes before that point?
Edit: Since your error-message reads: “…monogame…” are you sure you have monogame and extension working, ie have you run this project in an earlier state, or other previous project, to verify you have a good installation?
-Maybe some versions of libraries/add ons are out of sync with each other or something like that… I don’t use extended, so don’t know if you need to be worried about version compatability with regular monogame
… But I DID do little research, and found out you DON’T need to call LoadContent to do what you are doing… Your code matches the tutorial, it seems, so your problem might be in the setup of your editor / environment.
You can try to create a MonoGame project from a template as an easier starting point. If you’re using Visual Studio 2019, just follow these directions and see if the empty project compiles and runs for you.