I need to check which key is pressed if it is LeftArrow do something, if it is RightArrow do something else, but when none key is pressed the main cycslus must go on.
I have this code for this, but when the proces come to this part it just waiting for key press, it doesnt skip it when none key is pressed. And second porblem is that I need to change position of "+" in field by 1, Bud if I left the key pressed long time its move by XXX
if (Console.ReadKey(true).Key == ConsoleKey.LeftArrow)
{
int levo;
levo = pozice;
if (levo == 1) //Zajištění, že se nedosáhne hodnoty vyšší, než je rozsah pole
{
levo = levo + 1;
}
p18[levo - 1] = "*+*"; //Samotný posun panáčka
p18[levo] = " "; //Smazání panáčka z původní pozice
}
if (Console.ReadKey(true).Key == ConsoleKey.RightArrow)
{
int pravo;
pravo = pozice;
if (pravo == 18) //Zajištění, že se nedosáhne hodnoty vyšší, než je rozsah pole
{
pravo = pravo - 1;
}
p18[pravo + 1] = "*+*"; //Samotný posun panáčka
p18[pravo] = " "; //Smazání panáčka z původní pozice
}
Aucun commentaire:
Enregistrer un commentaire