C
C#8mo ago
HD-Fr0sT

The cursor wont move

what could i do?
6 Replies
HD-Fr0sT
HD-Fr0sTOP8mo ago
cursor stays still what could i do fix it? fixed it moving but does not move appropriately
int[,] grid = {
{1, 2, 3,},
{4, 5, 6,},
{7, 8, 9,},
};


int kolumn = 0;
int rad = 0;

ConsoleKeyInfo key;

Console.Clear();

for (int i = 0; i < grid.GetLength(0); i++)
{
for (int j = 0; j < grid.GetLength(1); j++)
{
Console.Write(grid[i,j]);
Console.Write(" ");
}

Console.WriteLine(" ");
}

while (true)
{




key = Console.ReadKey();

switch (key.Key)
{

case ConsoleKey.UpArrow:
kolumn++;
break;

case ConsoleKey.DownArrow:
kolumn--;
break;

case ConsoleKey.LeftArrow:
rad--;
break;

case ConsoleKey.RightArrow:
rad++;
break;
}

switch (kolumn)
{

case >2:
kolumn = 0;
break;

case <1:
kolumn = 2;
break;

}

switch (rad)
{
case >2:
rad = 0;
break;

case <1:
rad = 2;
break;
}


Console.SetCursorPosition(kolumn , rad);


}
int[,] grid = {
{1, 2, 3,},
{4, 5, 6,},
{7, 8, 9,},
};


int kolumn = 0;
int rad = 0;

ConsoleKeyInfo key;

Console.Clear();

for (int i = 0; i < grid.GetLength(0); i++)
{
for (int j = 0; j < grid.GetLength(1); j++)
{
Console.Write(grid[i,j]);
Console.Write(" ");
}

Console.WriteLine(" ");
}

while (true)
{




key = Console.ReadKey();

switch (key.Key)
{

case ConsoleKey.UpArrow:
kolumn++;
break;

case ConsoleKey.DownArrow:
kolumn--;
break;

case ConsoleKey.LeftArrow:
rad--;
break;

case ConsoleKey.RightArrow:
rad++;
break;
}

switch (kolumn)
{

case >2:
kolumn = 0;
break;

case <1:
kolumn = 2;
break;

}

switch (rad)
{
case >2:
rad = 0;
break;

case <1:
rad = 2;
break;
}


Console.SetCursorPosition(kolumn , rad);


}
Keswiik
Keswiik8mo ago
define "does not move appropriately"
HD-Fr0sT
HD-Fr0sTOP8mo ago
HD-Fr0sT
HD-Fr0sTOP8mo ago
the controls are also flipped btw this is an older version
Keswiik
Keswiik8mo ago
The limits for your columns do not look correct. You allow up to 2, yet each row actually has 5 characters (with numbers at 0, 2, and 4). Your checks on the lower limits for both rows and columns are also wrong. 0 is a valid position, but you wrap 0 back around to 2. So your only allowed positions are 1,2, which will lead to unintended column/row index changes.
HD-Fr0sT
HD-Fr0sTOP8mo ago
Make sense Also i could change consolesetposition items oriantation as well
Want results from more Discord servers?
Add your server