Skip to content

Instantly share code, notes, and snippets.

@playdeezgames
Created August 6, 2018 08:57
Show Gist options
  • Save playdeezgames/2c67d7cb20a6ab3308b0da9b1ca192f3 to your computer and use it in GitHub Desktop.
Save playdeezgames/2c67d7cb20a6ab3308b0da9b1ca192f3 to your computer and use it in GitHub Desktop.
Nothingland, in which an empy grid of squares is drawn, and the only choice the player has is when to end the game.
using System;
namespace Nothingland
{
internal class World
{
internal int BoardWidth = 8;
internal int BoardHeight = 8;
}
class Program
{
static void Main(string[] args)
{
Console.Title = "Nothingland";
Console.Clear();
Console.CursorVisible = false;
var world = new World();
var done = false;
while(!done)
{
RenderWorld(world);
done = HandleInput(world);
}
}
private static bool HandleInput(World world)
{
var key = Console.ReadKey(true);
switch(key.Key)
{
case ConsoleKey.Escape:
return true;
default:
return false;
}
}
private static void RenderWorld(World world)
{
for(int row=1;row<=world.BoardHeight;++row)
{
for(int column=1;column<=world.BoardWidth;++column)
{
Console.CursorLeft = column-1;
Console.CursorTop = row-1;
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.BackgroundColor = ConsoleColor.Black;
Console.Write(".");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment