/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { TextureGen = new Utility.TextureGenerator(GraphicsDevice); Boarders = new List <Tile>(); var ScreenHeight = graphics.GraphicsDevice.Viewport.Height; var ScreenWidth = graphics.GraphicsDevice.Viewport.Width; Boarders.Add(new Tile(TileTypes.Wall, TextureGen.CreateTexture(ScreenWidth, 1, Color.Brown), new Vector2(0, 0), Color.Brown)); Boarders.Add(new Tile(TileTypes.Wall, TextureGen.CreateTexture(ScreenWidth, 1, Color.Blue), new Vector2(0, ScreenHeight - 1), Color.Blue)); Boarders.Add(new Tile(TileTypes.Wall, TextureGen.CreateTexture(1, ScreenHeight, Color.Pink), new Vector2(0, 0), Color.Pink)); Boarders.Add(new Tile(TileTypes.Wall, TextureGen.CreateTexture(1, ScreenHeight, Color.Orange), new Vector2(ScreenWidth - 1, 0), Color.Orange)); Tiles = new Tile[] { new Tile(TileTypes.Snake, TextureGen.CreateTexture(10, 10, Color.White), new Vector2(-1, -1), Color.Red, false), new Tile(TileTypes.Food, TextureGen.CreateTexture(10, 10, Color.White), new Vector2(-1, -1), Color.Chocolate, false), new Tile(TileTypes.Wall, TextureGen.CreateTexture(10, 10, Color.White), new Vector2(-1, -1), Color.White, false) }; tCount = Tiles.Length - 1; cursor = Tiles[tCount]; level = new LevelUtility.Level(); paused = false; base.Initialize(); }
public Snake(Utility.TextureGenerator TextureGen, int Width, int Height) { _Texture = TextureGen.CreateTexture(Width, Height, Color.White); _EmptyTexture = TextureGen.CreateTexture(Width, Height, Color.Transparent); segmentsDictionary = new Dictionary <string, SnakeSegment>(); segmentsDictionary.Add("Head", createSegment(_Texture, new Vector2(5, 5), Color.Red)); _segmentCount = segmentsDictionary.Keys.Count; }
public static Level GenerateLevel(LevelBluePrint BluePrint, GraphicsDevice device) { Utility.TextureGenerator TextureGen = new Utility.TextureGenerator(device); var level = new Level(); for (int i = 0; i < BluePrint.Storage.Count; i++) { BluePrint.OpenPrint(i); var tile = new Tile((Tiles.TileTypes)Convert.ToInt32(BluePrint.TileType), TextureGen.CreateTexture(Convert.ToInt32(BluePrint.TileWidth), Convert.ToInt32(BluePrint.TileHeight), new Color(Convert.ToUInt32(BluePrint.Color))), new Microsoft.Xna.Framework.Vector2((float)Convert.ToInt32(BluePrint.X), (float)Convert.ToInt32(BluePrint.Y)), new Color(Convert.ToUInt32(BluePrint.Color))); level.AddTile(tile); } return(level); }
public Food(Random Random, Utility.TextureGenerator TextureGen, int Width, int Height) { _Texture = TextureGen.CreateTexture(Width, Height, Color.White); random = Random; }