So, I was bored and decided to write an ASCII game in C# for the fun of it, and I have drawing, clearing, updating, etc.. Although, I'm stuck at one part, input. I want to get input every frame, without the player pressing enter, So far the player has to press enter, but it doesn't do anything.
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
namespace ASCII
{
public static class Game
{
static string map = File.ReadAllText("Map.txt");
public static void Draw()
{
Console.CursorVisible = false;
Console.WriteLine(map);
}
public static void Update()
{
Clear();
Input();
}
public static void Input()
{
string input = Console.ReadLine();
switch (input)
{
case "a":
//Do something
break;
}
}
public static void Clear()
{
Console.Clear();
Draw();
}
}
}
As you can see in the Input()
void, it gets input every frame, but I only want to get it once, the do a move method or something that I will implement later.
BTW Map.txt displays this:
###################
# #
# @ # #
######## #
# #
# #
# #
# #
# #
# #
# #
###################