Created
August 6, 2018 08:57
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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