public static void Main() { // Create a window, 16 rows high and 40 columns across: ConsoleWindow console = new ConsoleWindow(16, 40, "Sunshine Console Hello World"); // Write to the window at row 6, column 14: console.Write(6, 14, "Hello World!", Color4.Lime); // Finally, update the window until a key is pressed or the window is closed: while (!console.KeyPressed && console.WindowUpdate()) { /* WindowUpdate() does a few very important things: ** It renders the console to the screen; ** It checks for input events from the OS, such as keypresses, so that they ** can reach the program; ** It returns false if the console has been closed, so that the program ** can be properly ended. */ } }
public Engine(IFovStrategy fovStrategy, ITileFactory tileFactory, World world, IInputHandler input, ILogController gameLog, ConsoleWindow console) { FovStrategy = fovStrategy; TileFactory = tileFactory; World = world; InputHandler = input; Console = console; if (ActorControllers == null) { ActorControllers = new List<IController>(); } if (FurnitureControllers == null) { FurnitureControllers = new List<IController>(); } GameLogController = gameLog; }
static void Main(string[] args) { // The title will appear at the top of the console window string consoleTitle = "Dungeons and @ Signs"; // Create the console rootConsole = new ConsoleWindow(_screenHeight, _screenWidth, consoleTitle); GenerateMap(); StartPlayer(); StartEnemy(); Global.GameState = GameStates.PlayerTurn; GameLoop(); var stats = Creature.GetDictionary(); Creature rat = stats["Rat"]; Console.Write("{0}, {1}, {2}", rat.Name, rat.Health, rat.Damage); }
public AsciiGraphicsComponent(ConsoleWindow console) { ConsoleWindow = console; }
public static class SunshineMain { // Here's a quick example. public static void Main() { ConsoleWindow console = new ConsoleWindow(21, 60, "Sunshine Console: The Roguelike"); int row = 10; // These 2 ints are the player's position. int col = 40; var sectionManager = new SectionManager(console); //Border Flags Example //sectionManager.AddSection("BorderFlags Example", new BorderedSection(new Section(0, 5, 10, 10, 2), new Symbol((char)219),BorderedSection.BorderSides.Rigth | BorderedSection.BorderSides.Left| BorderedSection.BorderSides.Top)); //Section Laying sectionManager.AddSection("Base", new Section(0, 0, 21, 60)); sectionManager.AddSection("Section Layer 1", new BorderedSection(new Section(2, 3, 10, 25, 1), new Symbol((char)219, Color4.Red))); sectionManager.AddSection("Section Layer 2", new BorderedSection(new Section(0, 0, 10, 10, 2), new Symbol((char)219, Color4.Green))); sectionManager.AddSection("Section Layer 3", new BorderedSection(new Section(7, 5, 7, 7, 3), new Symbol((char)219, Color4.Blue))); sectionManager.PrintToConsole(); // var baseS = sectionManager.GetSection("Base"); while (console.WindowUpdate()) // WindowUpdate() returns false if the window is closed, so be sure to check for that. // baseS.Clear(); { Section movingSection = sectionManager.GetSection("Section Layer 2"); movingSection.SetTextLine("Testing".ToSymbolArray(), 1, 1); movingSection.SetTextLine("This".ToSymbolArray(), 2, 1); movingSection.SetTextLine("Section".ToSymbolArray(), 3, 1); if (console.KeyPressed) // KeyPressed returns true if there's a new key to grab. { switch (console.GetKey()) // If KeyPressed is false, GetKey() will return Key.Unknown. { case Key.Up: movingSection.PinY--; row = Math.Max(0, row - 1); // In our basic example, we only check for arrow keys. break; case Key.Down: movingSection.PinY++; row = Math.Min(row + 1, 19); // We make sure that row & col don't go beyond the edges of the map. break; case Key.Left: movingSection.PinX--; col = Math.Max(0, col - 1); break; case Key.Right: movingSection.PinX++; col = Math.Min(col + 1, 59); break; } } // baseS.Clear(); sectionManager.PrintToConsole(); System.Threading.Thread.Sleep(10); // A call to Sleep() will prevent our program from using 100% CPU all the time.*/ } // And that's all you really need to get up and running! }
static void Main(string[] args) { bool inSession = false; int menuSelectionMade = -1; Console.WriteLine("Starting..."); // Add console ConsoleWindow console = new ConsoleWindow(50, 120, "Enfilade"); // Main menu while (menuSelectionMade == -1) { console.Write(1, 1, "Enfilade", Color4.White); console.Write(2, 1, "--------", Color4.White); console.Write(3, 1, "a. Start", Color4.White); console.Write(4, 1, "b. Quit", Color4.White); console.WindowUpdate(); //KeyInfo cki; //cki = Console.ReadKey(); /*while (!console.KeyPressed) { }*/ if (console.KeyPressed) { Key key = console.GetKey(); switch (key) { case Key.A: menuSelectionMade = 0; break; case Key.B: menuSelectionMade = 1; break; } } } // If start game if (menuSelectionMade == 0) { WorldMap worldMap = new WorldMap(); TurnManager turnManager = new TurnManager(); Player player = new Player(); UI ui = new UI(); inSession = true; Console.CursorVisible = false; // Set references worldMap.console = console; worldMap.player = player; turnManager.console = console; turnManager.worldMap = worldMap; turnManager.player = player; turnManager.ui = ui; player.worldMap = worldMap; player.ui = ui; player.console = console; ui.console = console; ui.worldMap = worldMap; ui.turnManager = turnManager; ui.player = player; // Generate current floor worldMap.GenerateFloorMap(0); Console.WriteLine("Map built."); // Draw worldMap.UpdateTilesItems(); worldMap.UpdateFOW(); worldMap.Draw(); ui.Draw(); console.WindowUpdate(); Console.WriteLine("Entering world."); // Start the game turnManager.Run(); } }
public InputHandler(ConsoleWindow console) { Console = console; }