I am currently working on a small game-project with the goal to make a program using CSharp.
The project is a console app that has a text-based menu and starting screen and my current goal is to add audio playing as the app launches.
I have researched what I need in order to get music to play but I lack the assembly to do so.
Here is my code:
using System;
using System.Media;
namespace AntFightingSim
{
class Program
{
public static string[] menuButtons = new string[] { " Fight!(Press Space) ", " Exit The Game!(Press Escape)" };
public static bool appRunning = true;
public static string path;
public static int buttonCount = 0;
static void Main(string[] args)
{
path = "C:/Users/Spyros/OneDrive - Södertörn university/Project Folder/Csharp Projects/RandomProjects/AntFightingSim/Resources/Dragon Ball FighterZ - OST - Loading Theme.wav";
MenuMethod();
}
static void MenuMethod()
{
while (appRunning && buttonCount != 1)
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = path;
player.Load();
player.PlayLooping();
Console.WriteLine("ANT INVESTMENT SIMULATOR");
Console.WriteLine("Press any key to start");
Console.Write("\n");
Console.Write("\n");
Console.ReadKey(true);
Console.Write(menuButtons[0]);
Console.Write(menuButtons[1]);
ConsoleKeyInfo info = Console.ReadKey(true);
if (info.Key == ConsoleKey.Spacebar)
StartGame();
else if (info.Key == ConsoleKey.Escape)
{
buttonCount++;
}
}
while (appRunning && buttonCount == 1)
{
Console.Write("\n");
Console.Write("\n");
Console.WriteLine("Are you sure about that?(Press Escape Again)");
ConsoleKeyInfo info = Console.ReadKey(true);
if (info.Key == ConsoleKey.Escape)
{
appRunning = false;
}
}
}
static void StartGame()
{
buttonCount = 1;
}
}
static class Ant
{
public static int strength;
public static int dexterity;
public static int agility;
public static string name;
public static bool gender;
}
}
I googled the error:
The type or namespace name 'Media' does not exist in the namespace 'System' (are you missing an assembly reference?) [C:\Users\Spyros\OneDrive - Södertörn university\Project Folder\Csharp Projects\RandomProjects\AntFightingSim\AntFightingSim.csproj]
but I don't have the slightest clue as to how to get said assembly reference into Visual Studio Code. So far, Google has only given me 2004-2015 results for Visual Studio only.
Which leads me here. For the first time, I wrote and posted a question in StackOverflow out of desperation. Is there a way to add said namespace/different namespace or is it just not possible in Visual Studio Code? God Speed.
Edit:
After a bit of searching, i have figured out that the System.Media
namespace and its assembly (PresentationCore.dll) does not exist within the NuGet list.
Since i lack the knowledge of a proper assembly that helps me with my goal, i am now at the point where i need to ask for an altenative to System.Media
and its ability to play audio files.