static void Main(string[] args) { //Local variables is created bool loseGame = false, roomComplete = false, bombActivated = false, shotVisible = false; int highscore = 0, playerUsedActions = 0, roomCount = 1, movementEvent = 0, bombCount = 0; Random rnd = new Random(); //The first room is created Empty.NewBoard(); Wall.CreateRoom(); Wall.CreateMaze(); Door.CreateExit(); Key.SpawnKey(); Treasure.GenerateTreasures(); Treasure.SpawnAmmo(); Bomb.CreateBombs(); Enemy.CreateEnemies(roomCount); //The board is created gets its values Entities.Ruta[,] boardGrid = Entities.Board; Entities.UpdateVisibilityBoard(); Player.PlayerUpdateVisibility(); //Board is drawn on the Console Draw.DrawScreen(boardGrid, Entities.IsVisible); Draw.DrawControls(boardGrid, highscore, Player.Health, bombCount, Player.Ammo); /*for (int i = 0; i < Treasure.TreasureList.GetLength(1); i++) * { * Draw.Plot(Treasure.TreasureList[0, i], Treasure.TreasureList[1, i], Entities.Ruta.Treasure, (ConsoleColor)Treasure.TreasureList[3, i]); * }*/ Draw.Plot(Player.X, Player.Y, Entities.Ruta.Player, ConsoleColor.Green); Draw.Plot(Key.X, Key.Y, Entities.Ruta.Key, ConsoleColor.Cyan); //Draw.Plot(Enemy.X, Enemy.Y, Entities.Ruta.Enemie, ConsoleColor.Red); while (!loseGame && roomCount < 15) { Entities.BoardCopy = boardGrid; if (roomComplete) //Resets some values and creates a new random room but with more enemies { Entities.UpdateVisibilityBoard(); highscore += (1000 - playerUsedActions) * roomCount; playerUsedActions = 0; roomCount++; Wall.WallCount = 0; Entities.NumbOfKeys = 0; Enemy.NumberOfEnemies = 0; Player.X = 1 + rnd.Next(boardGrid.GetLength(1) - 2); Player.Y = 1 + rnd.Next(boardGrid.GetLength(0) - 2); Key.KeyCount = 0; Empty.NewBoard(); Wall.CreateRoom(); Wall.CreateMaze(); Door.CreateExit(); Key.SpawnKey(); Treasure.GenerateTreasures(); Treasure.SpawnAmmo(); Bomb.CreateBombs(); Enemy.CreateEnemies(roomCount); Draw.DrawScreen(boardGrid, Entities.IsVisible); Draw.DrawControls(boardGrid, highscore, Player.Health, bombCount, Player.Ammo); /*for (int i = 0; i < Treasure.TreasureList.GetLength(1); i++) * { * Draw.Plot(Treasure.TreasureList[0, i], Treasure.TreasureList[1,i], Entities.Ruta.Treasure, (ConsoleColor) Treasure.TreasureList[3,i]); * }*/ Draw.Plot(Player.X, Player.Y, Entities.Ruta.Player, ConsoleColor.Green); //Draw.Plot(Enemy.X, Enemy.Y, Entities.Ruta.Enemie, ConsoleColor.Red); roomComplete = false; } if (Player.MovePlayer()) { Bomb.BombSetOf(Player.Y, Player.X); } Player.PlayerUpdateVisibility(); playerUsedActions++; movementEvent = Player.UpdatePlayerPosititon(); if (movementEvent == 1) { roomComplete = true; } else if (movementEvent == 2) { Bomb.BombCount++; } highscore += Treasure.FoundTreasure(Player.X, Player.Y); for (int i = 0; i < roomCount * 10; i++) { Enemy.MoveEnemy(i, Player.X, Player.Y); Player.Health -= Enemy.UpdateEnemyPosititon(i); } for (int i = 0; i < boardGrid.GetLength(0); i++) { for (int j = 0; j < boardGrid.GetLength(1); j++) { if (Entities.Board[i, j] == Entities.Ruta.Shot && shotVisible) { Entities.Board[i, j] = Entities.Ruta.Empty; shotVisible = false; } if (Entities.Board[i, j] == Entities.Ruta.Shot) { shotVisible = true; } Player.PlayerUpdateVisibility(); if (Entities.Board[i, j] != Entities.BoardCopy[i, j] || Entities.IsVisible[i, j]) { if (Entities.Board[i, j] == Entities.Ruta.Player) { Draw.Plot(j, i, Entities.Ruta.Player, ConsoleColor.Green); } else if (Entities.Board[i, j] == Entities.Ruta.Enemie) { Draw.Plot(j, i, Entities.Ruta.Enemie, ConsoleColor.Red); } else if (Entities.Board[i, j] == Entities.Ruta.Key) { Draw.Plot(j, i, Entities.Ruta.Key, ConsoleColor.Cyan); } else if (Entities.Board[i, j] == Entities.Ruta.Treasure) { Draw.Plot(j, i, Entities.Ruta.Treasure, ConsoleColor.Yellow); } else if (Entities.Board[i, j] == Entities.Ruta.Bomb) { Draw.Plot(j, i, Entities.Ruta.Bomb, ConsoleColor.Gray); } else { Draw.Plot(j, i, Entities.Board[i, j], ConsoleColor.White); } } } } /* * if (Player.PrevX != Player.X || Player.PrevY != Player.Y) * { * Draw.Plot(Player.PrevX, Player.PrevY, Entities.Board[Player.PrevY, Player.PrevX], ConsoleColor.Black); * Draw.Plot(Player.X, Player.Y, Entities.Ruta.Player, ConsoleColor.Green); * }*/ /* * for (int i = 0; i < roomCount * 2; i++) * { * Enemy.MoveEnemy(i, Player.X, Player.Y); * Player.Health -= Enemy.UpdateEnemyPosititon(i); * if (Enemy.PrevX != Enemy.X || Enemy.PrevY != Enemy.Y) * { * Draw.Plot(Enemy.PrevX, Enemy.PrevY, Entities.Ruta.Empty, ConsoleColor.Black); * if (Enemy.PrevX == Player.X && Enemy.PrevY == Player.Y) * { * Draw.Plot(Player.X, Player.Y, Entities.Ruta.Player, ConsoleColor.Green); * } * else * { * Draw.Plot(Enemy.X, Enemy.Y, Entities.Ruta.Enemie, ConsoleColor.Red); * } * } * } */ bombCount = Bomb.BombCount; Draw.DrawControls(boardGrid, highscore, Player.Health, bombCount, Player.Ammo); Console.SetCursorPosition(0, boardGrid.GetLength(0) + 2); Console.WriteLine(playerUsedActions); if (Player.Health <= 0) { loseGame = true; } } Draw.DrawGameOver(highscore); Console.ReadLine(); }
static void Main(string[] args) { Render mainView = new Render(); mainView.height = 57; mainView.width = 200; mainView.background = ' '; mainView.border = '~'; mainView.addBorder = true; Character cursor = new Character(); cursor.x = 6; cursor.y = 9; cursor.xs = 5; cursor.ys = 8; cursor.xf = 199; cursor.yf = 54; Menu mainSprawl = new Menu(); string[,] mainSprawlOptions = { { "File", "file" }, { "Edit", "edit" }, { "Tools", "tools" }, { "About", "about" } }; mainSprawl.options = mainSprawlOptions; //dropdowns: Menu fileDrop = new Menu(); string[,] fileDropOptions = { { "New", "new" }, { "Open", "open" }, { "Save", "save" }, { "Save As", "saveas" } }; fileDrop.options = fileDropOptions; Menu editDrop = new Menu(); string[,] editDropOptions = { { "Format", "format" }, { "Transform", "transform" } }; editDrop.options = editDropOptions; Menu toolsDrop = new Menu(); string[,] toolsDropOptions = { { "Point Single", "single" }, { "Perpendicular Line", "perpline" }, { "Box", "box" }, { "Sprite", "sprite" } }; toolsDrop.options = toolsDropOptions; Menu aboutDrop = new Menu(); string[,] aboutDropOptions = { { "About", "about" }, { "Help", "help" } }; aboutDrop.options = aboutDropOptions; char[,] workspace = new char[45, 193]; for (int i = 0; i < 45; i++) { for (int j = 0; j < 193; j++) { workspace[i, j] = '$'; } } Top: Console.Clear(); char[,] viewport = mainView.Default(); //Top menu bar Draw.PerpendicularLine(viewport, mainView.border, 2, 1, 2, 199); Draw.Sentence(viewport, "ASCII DRAW 1.0", 1, 2); Draw.PerpendicularLine(viewport, mainView.border, 1, 17, 1, 199); //Top sprawl menu mainSprawl.Sprawl(viewport, '|', 3, 2); Draw.PerpendicularLine(viewport, mainView.border, 4, 1, 4, 199); //Bottom bar Draw.PerpendicularLine(viewport, mainView.border, 54, 1, 54, 199); //Number guides Draw.PerpendicularLine(viewport, mainView.border, 8, 5, 8, 199); Draw.PerpendicularLine(viewport, mainView.border, 9, 5, 53, 5); for (int i = 0; i < 45; i++) { string input = Convert.ToString(i); Draw.Sentence(viewport, input, i + 9, 2); if (i == cursor.y - 9) { Draw.Sentence(viewport, "--", i + 9, 2); } } for (int i = 0; i < 193; i++) { string input = Convert.ToString(i); if (i == cursor.x - 6) { input = "||"; } char[] digits = input.ToCharArray(); for (int j = 0; j < digits.Length; j++) { Draw.Single(viewport, digits[j], 7 - j, i + 6); } } //Coordinate indicator Draw.Sentence(viewport, $"x: {cursor.x - 6}, y: {cursor.y - 9}", 55, 2); //Workspace for editing Draw.Sprite(viewport, workspace, 9, 6); //Draw cursor cursor.Initialize(viewport); //Dropdown menus //tools fileDrop.Dropdown(viewport, '#', 4, 2, 20); editDrop.Dropdown(viewport, '#', 4, 12, 20); toolsDrop.Dropdown(viewport, '#', 4, 22, 20); aboutDrop.Dropdown(viewport, '#', 4, 33, 20); mainView.Display(viewport); if (fileDrop.isOpen == true) { switch (fileDrop.GetInput()) { case "new": break; case "open": break; case "save": break; case "saveas": break; } } else if (editDrop.isOpen == true) { switch (editDrop.GetInput()) { case "format": break; case "transform": break; } } else if (toolsDrop.isOpen == true) { switch (toolsDrop.GetInput()) { case "single": break; } } else if (aboutDrop.isOpen == true) { switch (aboutDrop.GetInput()) { case "about": break; case "help": break; } } else { switch (mainSprawl.GetInput()) { case "file": fileDrop.isOpen = true; break; case "edit": editDrop.isOpen = true; break; case "tools": toolsDrop.isOpen = true; break; case "about": aboutDrop.isOpen = true; break; } } goto Top; }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here string name = "moshe"; moshe = new Player(name); #region background clouds1Texture = Content.Load<Texture2D>("background/clouds1"); clouds2Texture = Content.Load<Texture2D>("background/clouds2"); clouds1 = new Draw(clouds1Texture, new Vector2(0,-150), null, Color.White, 0, new Vector2(0, 0), new Vector2(1f), SpriteEffects.None, 0); clouds2 = new Draw(clouds2Texture, new Vector2(-800,-150), null, Color.White, 0, new Vector2(0, 0), new Vector2(1f), SpriteEffects.None, 0); #endregion }