Since your help with my first issue, I have made some great progress with the RPG
I'm making for both educational and recreational purposes. Thank you all for that!
In this post, I will be asking for a solution to 2 problems I've encountered: the first problem is the following:
Now that the movement system is working properly, I've decided to start work on a map for the game. Creating this map is quite a time consuming, but making sure my program prints the map in color is even worse.
This is my method so far:
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.Write(@"^/\/\^^^ ^ /\/\ /\^^/\^/\^^^ ^ ^/\/\^/\/\ /\^^/\ ");
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("ooo~o~o~oo~o~~o~oo~");
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.Write(@"^^/\^/\^/\^^/\ ^/\^^^^ /\ /\/\ /\ ^^ ^/\^/\/\^/\^ ^^");
Console.Write(@"^^/\^/\/\/\^/\^/\^/\/\^ /\ ^ ^ ^^ /\^/\^^/\^^^^^/\ ");
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("oo~~~~~oooo~oo~~o~o");
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("....|....|||....|.|.|.|.|..|.....||..|..||.|.|.");
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.Write(@"^/\/\ ^");
Since my console has a width of 128, this rather large and repetitive chunk of code is to create only two lines of my 32 line map (of which I need to create multiple to create a larger game).
Making the whole map like this would be way too time-consuming (and annoying). Is there a better, more efficient way of creating a map for an RPG
(or any type of ASCII
game for that matter), which a beginner like myself would be able to understand and create?
The second issue I have is the player character. I have not yet found a way to get an '@' symbol to appear on the cursor and to get that @
to move with the cursor when I press a button. This is the code I have for my movement system:
while (true)
{
ConsoleKeyInfo input = Console.ReadKey(true);
PosX = Console.CursorLeft;
PosY = Console.CursorTop;
switch (input.KeyChar)
{
case 'w':
if (PosY > 1)
{
Console.SetCursorPosition(PosX + 0, PosY - 1);
PosX = Console.CursorLeft;
PosY = Console.CursorTop;
}
break;
case 'a':
if (PosX > 1)
{
Console.SetCursorPosition(PosX - 1, PosY + 0);
}
break;
case 's':
if (PosY < 31 )
{
Console.SetCursorPosition(PosX + 0, PosY + 1);
}
break;
case 'd':
if (PosX < 127)
{
Console.SetCursorPosition(PosX + 1, PosY + 0);
}
break;
}
}
As you can see: this is a loop, which constantly checks if a button is pressed and it moves the cursor accordingly.
How would I make sure there is an @
symbol on the cursor at all times, without getting rid of the map character it was on if the @
symbol moves?