I'm trying to create a new class that is supposed to have these variables in its code:
class Map
{
// Variable declaration
public int Width { get; set; } // Width of map in tiles
public int Height { get; set; } // Height of map in tiles
public int TileWidth { get; set; }
public int TileHeight { get; set; }
}
but for some reason, after creating a new Map class in Game1.cs, I can't seem to acccess things such as Width and Height.
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
public static SpriteBatch spriteBatch;
// etc...
// Class initialization
Map map = new Map();
map.Width = 10; // Won't work, says it is a 'field' but used like a 'type'
}
I figure I'm not trying to set the property right, but I'm not sure how to actually do so.
I get two error messages when attempting the above:
'Deep.Game1.Map' is a 'field' but used like a 'type'
and
Invalid token '=' in class, struct, or interface member declaration