Professional Documents
Culture Documents
Aguirre Prog Lang TP
Aguirre Prog Lang TP
Aguirre Prog Lang TP
The first game is a simple rpg game. The player will be given options, fight , rest, or quit.
When the player chooses to fight, he/she will generate a random attack damage to the monster.
He wins when the monster dies, and loses when his hp runs out.
Game 2: Guess the Number
The player guesses a number from 1-100. It will show if the number is too high or too
low. When the player guesses wrong he will be asked to give another number. When he
guesses right he will win.
CODES
SIMPLE RPG
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to Simple RPG Game!");
Console.WriteLine("Create your character:");
while (true)
{
Console.WriteLine("\nChoose an action:");
Console.WriteLine("1. Fight");
Console.WriteLine("2. Rest");
Console.WriteLine("3. Quit");
switch (choice)
{
case "1":
Fight(player);
break;
case "2":
Rest(player);
break;
case "3":
Console.WriteLine("Thanks for playing!");
return;
default:
Console.WriteLine("Invalid choice. Try again.");
break;
}
}
}
while (true)
{
Console.WriteLine("\n1. Attack");
Console.WriteLine("2. Run");
switch (choice)
{
case "1":
// Player attacks the enemy
int damageDealt = rand.Next(player.Attack - 5, player.Attack + 6);
enemyHealth -= damageDealt;
Console.WriteLine($"You deal {damageDealt} damage to the enemy.");
if (enemyHealth <= 0)
{
Console.WriteLine("You defeated the monster!");
return;
}
if (player.Health <= 0)
{
Console.WriteLine("You were defeated by the monster!");
return;
}
break;
case "2":
Console.WriteLine("You ran away!");
return;
default:
Console.WriteLine("Invalid choice. Try again.");
break;
}
}
}
class Character
{
public string Name { get; set; }
public int Health { get; set; }
public int Attack { get; set; }
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to Guess the Number Game!");
Console.WriteLine("I have selected a random number between 1 and 100.");
while (!guessedCorrectly)
{
Console.Write("Enter your guess: ");
string input = Console.ReadLine();
attempts++;