-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started π
Leon Schimmel edited this page Mar 2, 2025
·
8 revisions
- Open your project folder
- Open your projects NuGet package manager
- Search for ConsoleNexusEngine by the author BlyZe
- Install the newest version
- Congrats! You can now start to make your first game π₯³
using ConsoleNexusEngine;
using ConsoleNexusEngine.IO;
public sealed class TestGame : NexusConsoleGame
{
public TestGame()
{
}
protected override void Load()
{
// Called once before the start of the game.
// Import game files and load resources here.
}
protected override void Update(in NexusInputCollection inputs)
{
// Called every frame and contains the input that were made last frame.
}
protected override void OnCrash(Exception exception)
{
// Called once if an unhandled exception occurs.
// Show the user an error message and write into a log here.
}
protected override void CleanUp()
{
// Called once after stopping the game.
// Clean up used files or stop music here
}
}// Set the allowed input types
Settings.InputTypes = NexusInputType.All;
// Set the color palette of the console
Settings.ColorPalette = new WindowsColorPalette();
// Set the font family and size of the console
Settings.Font = new NexusFont("Terminal", new NexusSize(25));
// Set the key that should immediately stop the game
Settings.StopGameKey = NexusKey.Escape;
// Set the title of the console
Settings.Title = "My first game";To use this code block you need to add the namespace ConsoleNexusEngine.Helpers
// If the current console window is a conhost.exe process, this returns true
if (!NexusEngineHelper.IsSupportedConsole())
{
// This restarts the whole program in a conhost.exe process, so better use it at the start of the program
// Due to Windows limitations this is the only way to properly ensure that the current window is a conhost.exe process
// Optionally you can request to start the app as administrator
NexusEngineHelper.StartInSupportedConsole();
return;
}// Create the game in a using block because it's disposable
// It's good practise to use a using block to make sure the game is properly disposed after it ended
using (var game = new TestGame())
{
// This starts the game and blocks the current thread until the game is stopped by using the StopGameKey
game.Start();
// This stops the console game and shuts down the game thread
game.Stop();
}