❔ Is there a way to not let there be user inputs in the terminal?

So it's been like 3 days since I started learning c#, and I wanted to make a small simple game about pokemon battles. Everything works just fine (I haven't finished it yet), but is there a way to not get user inputs in the terminal?
10 Replies
Bepool 🍟
Bepool 🍟OP2y ago
Bepool 🍟
Bepool 🍟OP2y ago
This is the code in Main
Thinker
Thinker2y ago
not be user input?
Bepool 🍟
Bepool 🍟OP2y ago
to be honest i dont know what i'm saying, im not very good at english how do i not get the r inside the terminal
Buddy
Buddy2y ago
Console.ReadKey Method (System)
Obtains the next character or function key pressed by the user.
Bepool 🍟
Bepool 🍟OP2y ago
using System;
class Program
{
static void Main(string[] args)
{
//Adds visual settings
Console.Title = ("Pokemon Battle Arena");
Console.ForegroundColor = ConsoleColor.Yellow;

Pokemon pikachu = new Pokemon("Pikachu", "Thundershock"); //Setting for Pikachu
Pokemon squirtle = new Pokemon("Squirtle", "Aqua Jet"); //Setting for Squirtle

//Pikachu's moveset
while (true)
{
//Makes a variable to check when a key is pressed
ConsoleKeyInfo keyInfo = Console.ReadKey();

// Check if the pressed key is 'Enter'
if (keyInfo.Key == ConsoleKey.Enter)
{
pikachu.CastAbility();
}

// Check if the pressed key is 'R'
if (keyInfo.Key == ConsoleKey.R)
{
pikachu.Rest();
}

//Stops the program after pressing 'Esc'
if (keyInfo.Key == ConsoleKey.Escape)
{
break;
}
}

}
}
using System;
class Program
{
static void Main(string[] args)
{
//Adds visual settings
Console.Title = ("Pokemon Battle Arena");
Console.ForegroundColor = ConsoleColor.Yellow;

Pokemon pikachu = new Pokemon("Pikachu", "Thundershock"); //Setting for Pikachu
Pokemon squirtle = new Pokemon("Squirtle", "Aqua Jet"); //Setting for Squirtle

//Pikachu's moveset
while (true)
{
//Makes a variable to check when a key is pressed
ConsoleKeyInfo keyInfo = Console.ReadKey();

// Check if the pressed key is 'Enter'
if (keyInfo.Key == ConsoleKey.Enter)
{
pikachu.CastAbility();
}

// Check if the pressed key is 'R'
if (keyInfo.Key == ConsoleKey.R)
{
pikachu.Rest();
}

//Stops the program after pressing 'Esc'
if (keyInfo.Key == ConsoleKey.Escape)
{
break;
}
}

}
}
ok
Buddy
Buddy2y ago
ReadKey accepts a boolean as an overload
Determines whether to display the pressed key in the console window. true to not display the pressed key; otherwise, false.
Bepool 🍟
Bepool 🍟OP2y ago
ohh so ReadKey(True) wont display it ok!! ty
Buddy
Buddy2y ago
Anytime. Good luck with your game!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server