/// <summary> /// Called when the DrawableGameComponent needs to be drawn. Override this method with /// component-specific drawing code. /// </summary> /// <param name="gameTime">Time passed since the last call to Draw.</param> public virtual void Draw(TickCount gameTime) { // Update the FPS _fps.Update(gameTime); // Clear the screen _game.RenderWindow.Clear(DrawingManager.BackgroundColor); // Draw the active non-console screen var ancs = ActiveNonConsoleScreen; if (ancs != null) { ancs.Draw(gameTime); } // Draw the console var cs = ConsoleScreen; if (ShowConsole && cs != null) { cs.Draw(gameTime); } // Draw the console if (ShowConsole && ConsoleScreen != null) { ConsoleScreen.Draw(gameTime); } }
public override void Draw(Sprite sprite) { foreach (var pixel in sprite) { pixel.Draw(this); } ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite)); }
public void Draw(ConsoleScreen screen, int left, int top) { screen.SetColor(PaletteColor.Text); screen.Draw(Label, left, top); int offset = left + Label.Length + 1; screen.SetColor(PaletteColor.Accessory); screen.Draw('<', offset, top); offset += 1; screen.SetColor(PaletteColor.Text); screen.Draw(SelectedOption.Label, offset, top); offset += SelectedOption.Label.Length; screen.SetColor(PaletteColor.Accessory); screen.Draw('>', offset, top); }
/// <summary> /// Draw the menu at the given screen position. /// </summary> /// <param name="screen">The screen to draw on</param> /// <param name="left">Position along X-axis in columns</param> /// <param name="top">Position along Y-axis in rows</param> public void Draw(ConsoleScreen screen, int left, int top) { for (int i = 0; i < Items.Count; i++) { if (Items[i] == SelectedItem) { screen.SetColor(PaletteColor.Highlight); screen.Draw(">", left, top + i); } Items[i].Draw(screen, left + 2, top + i); } }
public override void Draw(Sprite sprite) { var xc = sprite.X + sprite.Width / 2; var yc = sprite.Y - sprite.Height / 2; foreach (var pixel in sprite) { var xn = xc + (pixel.X - xc) * Math.Cos(sprite.Angle) + (pixel.Y - yc) * Math.Sin(sprite.Angle); var yn = yc - (pixel.X - xc) * Math.Sin(sprite.Angle) + (pixel.Y - yc) * Math.Cos(sprite.Angle); var rep = pixel.Clone(); rep.Set(xn, yn); rep.Draw(this); } ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite)); }
public void Run() { _commands = new Queue <Commands>(); _commandMultiplier = 1; _consoleScreen.Init(_width, _height); Scene scene = new Scene(_width, _height); // Create separate thread to listen key inputs from user var inputsThread = new Thread(ListenKeys); inputsThread.Start(); // TODO Handle closing event _commandsToLog = new StringBuilder(); while (true) { if (scene.Calculate()) { lock (_sync) { _commands.Clear(); // Forget all previous commands that were not executed. _commandsToLog.Clear(); _commandMultiplier = 1; } } _consoleScreen.Draw(scene); _consoleScreen.DrawDebug("Commands queued: " + _commandsToLog); _consoleScreen.DrawDebug("Multiplier: " + _commandMultiplier); if (!HandleUserInput(scene)) { break; } Thread.Sleep(400); } }
private static void DisplayGame() { // Display the map. for (int y = 0; y < _map.Height; ++y) { for (int x = 0; x < _map.Width; ++x) { Tile tile = _map.Tiles[x, y]; switch (tile) { case Tile.HorizontalWall: ConsoleScreen.Write(x, y, '-'); break; case Tile.VerticalWall: ConsoleScreen.Write(x, y, '|'); break; case Tile.Door: ConsoleScreen.Write(x, y, '+', ConsoleColor.Green, ConsoleColor.Black); break; case Tile.Floor: default: ConsoleScreen.Write(x, y, ' '); break; } } } // Display the player. ConsoleScreen.Write(_player.X, _player.Y, '@', ConsoleColor.DarkCyan, ConsoleColor.Black); // Display the enemies. foreach (Enemy enemy in _map.Enemies) { ConsoleScreen.Write(enemy.X, enemy.Y, 'e', ConsoleColor.Red, ConsoleColor.Black); } // Draw to the console screen. ConsoleScreen.Draw(); }
public void Draw(ConsoleScreen screen, int left, int top) { screen.SetColor(PaletteColor.Text); screen.Draw(Text, left, top); }
public override void Draw(CharPixel pixel) { ConsoleScreen.Draw(pixel.X, pixel.Y, pixel.Color, () => Console.Write(pixel.Value)); }