Witam. Jestem początkowym programistą. Uczy mnie tata. Ale mam problem. Zrobiłem grę typu snake, ale mam problem z wyglądem do jak idzie do góry lub do dołu. Oto stringi węży:
Do dołu:
waz = "|"+"\n"+spacje+"o";
Do góry:
waz = "o"+"\n"+spacje+"|";
Oto kod całego programu:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
public static string waz = "";
public static int MAXX=50;
public static int MAXY=50;
static void Main(string[] args)
{
string entery = "";
string spacje = "";
string wyswietlane = "";
bool iscontinue = true;
int x = 0;
int y = 0;
while (iscontinue)
{
ConsoleKeyInfo Info = Console.ReadKey();
if (Info.Key == ConsoleKey.RightArrow)
{
x = x + 1;
waz = "-o";
}
if (Info.Key == ConsoleKey.DownArrow)
{
y = y + 1;
waz = "|"+"\r"+spacje+"o";
}
if (Info.Key == ConsoleKey.UpArrow)
{
y = y - 1;
waz = "o\n" + spacje + "|";
if (y < 0)
y = MAXY - 1;
}
if (Info.Key == ConsoleKey.LeftArrow)
{
x = x - 1;
waz = "o-";
if (x < 0)
x = MAXX - 1;
}
rysuj(x,y,out x, out y);
}
}
public static string SetChar(int k, string s)
{
string ret = "";
for (int l = 0; l < k; l++)
ret += s;
return ret;
}
public static void rysuj(int x, int y, out int rx, out int ry)
{
Console.Clear();
string spacje = "";
string entery = "";
for(int k=0;k<MAXX;k++)
{
for(int l=0;l<MAXY;l++)
{
//x,y
if (k==x && l==y)
{
//string który ma k-stacji i l-enterów
entery = SetChar(y, "\n");
spacje = SetChar(x, " ");
Console.Write(entery + spacje+ waz);
break;
}
}
}
if(x>MAXX)
{
rx = 0;
}
else
{
rx = x;
}
if (y > MAXY)
{
ry = 0;
}
else
{
ry = y;
}
}
}
}
Proszę o szybką odpowiedz