Visual Studio work (Pt1)
Creating the start menu for a game
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
//Basic if statement setup
if (true)
{
//do this thing
}
int playerHealth = 10;
if (playerHealth > 0)
{
Console.WriteLine("Player is still alive");
}
//Relational Operators
// '>' = Greater Than
// '<' = Less Than
// '==' = Equals to
// playerHealth == 10; <-- Checking if playerhealth is equal to 10
// player = 10; <-- Sets the playerhealth to 10
// '>=' = Greater than or equals to
// '<=' = Less than or equal to
// '!=' = Not equal to
if (playerHealth != 0)
{
Console.WriteLine("Player health does not equal 0");
}
//if the first statement is false4
// use an else if to check another statement
else if (playerHealth <= 0)
{
Console.WriteLine("Players health is less than or equals to 0");
}
//if all statements are false, run this as a defualt
else
{
Console.WriteLine("Error! Something went wrong!");
}
{
Console.WriteLine("Welcome to Fortnite 2.0");
int choice = int.Parse(Console.ReadLine());
Console.WriteLine("1 Play");
if (choice == 1)
{
Console.WriteLine("Starting game!");
}
Console.WriteLine("2 Settings");
if (choice == 2)
{
Console.WriteLine("Settings menu!");
}
Console.WriteLine("3 Quit");
if (choice == 3)
{
Console.WriteLine("Quitting game");
}
}
}
}
}
No comments:
Post a Comment