protected override void Initialize() { Pixelclass.Content = Content; Actor.Dimentions = new Point(32, 32); Level.m_LayerSize = Actor.Dimentions; m_level = new Level(); m_Player = new Player(); m_input = new InputManager(); m_cam = new Camera(GraphicsDevice.Viewport); base.Initialize(); //m_level.m_mazeGen.GenerateMaze(new MazeInfo(new Point(65, 65), 10, 2, 2, 100)); m_Player.VirtualPosition = m_level.m_StartPos; }
public void UpdateMe(GameTime gt,Player player,InputManager input) { if (input.WasPressedBack(Keys.Enter)) { if (player.VirtualPosition == m_WinPos) { Height++; if (Height % 10 == 0) RegenTown(); else RegenMaze(); player.VirtualPosition = m_StartPos; } else if (player.VirtualPosition == m_StartPos) { Height--; if (Height % 10 == 0) RegenTown(); else RegenMaze(); player.VirtualPosition = m_WinPos; } } if (input.IsDown(Keys.Space)) { Rectangle temprect; temprect = m_mazeGen.m_rooms[Game1.RNG.Next(0, m_mazeGen.m_rooms.Count)]; m_enemies.Add(new Enemy(new Point(temprect.X + Game1.RNG.Next(1, temprect.Width - 1), temprect.Y + Game1.RNG.Next(1, temprect.Height - 1)))); } for (int i = 0; i < m_enemies.Count; i++) m_enemies[i].UpdateMe(gt, this); }
public void DrawMap(SpriteBatch sb,Player p) { Vector2 temp = new Vector2(Game1.graphics.PreferredBackBufferWidth / 2, Game1.graphics.PreferredBackBufferHeight / 2); int size = 4; temp.X -= (Map.GetLength(0)*size) / 2; temp.Y -= (Map.GetLength(1) * size) / 2; for (int x = 0; x < Map.GetLength(0); x++) { for (int y = 0; y < Map.GetLength(1); y++) { if (Map[x, y] == 0) { sb.Draw(Pixel, new Rectangle((x *size) + (int)temp.X, (y * size) + (int)temp.Y, size, size), Color.White * 0.2f); } } } for (int i = 0; i < m_enemies.Count; i++) m_enemies[i].DrawMap(sb,temp); p.DrawMap(sb, temp); sb.Draw(Pixel, new Rectangle((m_WinPos.X * size) + (int)temp.X, (m_WinPos.Y * size) + (int)temp.Y, size, size), Color.Green * 0.5f); sb.Draw(Pixel, new Rectangle((m_StartPos.X * size) + (int)temp.X, (m_StartPos.Y * size) + (int)temp.Y, size, size), Color.Red * 0.5f); }