Get started with Visual Studio | SadConsole v10 (2024)

This page describes how to create a new project based on SadConsole Standard using .NET 6.0 and Visual Studio.

Before using Visual Studio, you'll need to install the SadConsole project templates. The first few sections of the Create a new SadConsole .NET project with the SadConsole templates. article describes how to do this. Follow those instructions and then come back to this article.

Prerequisites

  1. Download and install Visual Studio 2022.

  2. During install, make sure that you select the .NET Core cross-platform development workload.

    • If you have already installed Visual Studio, you can run the Visual Studio Installer that was added to your computer, and modify your installation to add the .NET Core cross-platform development workload.
  3. Install the SadConsole templates with the dotnet command: dotnet new --install SadConsole.Templates. For more information, see Create a new SadConsole .NET project with the SadConsole templates

Create a new project

Start Visual Studio.

  1. In the Create a new project dialog, type `sadconsole`` into the search box and select the SadConsole Game (MonoGame) project template.

    Get started with Visual Studio | SadConsole v10 (1)

    The SadConsole Game (MonoGame) template creates a SadConsole game that uses MonoGame and the SadConsole Game (SFML) template creates a game that uses SFML. MonoGame and SFML are the backend renderers for SadConsole. In general, the code you use for SadConsole doesn't care which rendering system you use. However, as your game progresses, which renderer you choose is very important. Currently, it's recommended that you use the MonoGame renderer as it has the following benefits:

    • Easier cross-platform targeting.
    • Supports 3D rendering: models, scenes, etc.
    • Built for .NET coding

    SFML is cross-platform, but it takes more work on your side to get that working.

  2. Press Next and then set the Project name to SadConsoleGame and choose a location on your computer to save the project.

Congratulations, you have a new project! Press F5 to run the game:

Get started with Visual Studio | SadConsole v10 (2)

Creating a project without a template

If you want to create a project without using the SadConsole templates, it's also pretty easy to do.

  1. Create a new Console App with either C# or VB.NET. Don't create a Console App (.NET Framework) project!

  2. Press Next and follow the wizard to set the name of the project to SadConsoleGame.

  3. Set the Location of your project code, and then press Next. and then choose where you want to save your code.

  4. Set the Framework to .NET 6.0 or later.

  5. Make sure that Do not use top-level statements is unchecked unless you know what you're doing and can convert the code in the next section.

  6. Press Create.

  7. Next, add the NuGet SadConsole MonoGame renderer package to the project.

    1. In the Solution Explorer, right-click on the project and select Manage NuGet Packages. This will display the NuGet package manager.
    2. Search for SadConsole and install the SadConsole.Host.MonoGame package.
    3. Search for MonoGame.Framework and install the MonoGame.Framework.DesktopGL package.

Congratulations, you have all of the required libraries to start creating a SadConsole game!

Configure the startup code

You need perform a minor modification to the project file, and then change the startup code that was automatically generated for your project.

Project file

  1. In the Solution Explorer window, double-click the project file, SadConsoleGame. This opens the project XML editor.

  2. Change the <OutputType>Exe</OutputType> element to <OutputType>WinExe</OutputType>.

    This alteration makes it so that only the SadConsole game window pops up when you run it. Without this change, you'll have two windows appear, the SadConsole game window and a .NET console.

  3. Just below the <OutputType> element, add <RootNamespace>SadConsoleGame</RootNamespace>.

  4. Before the end of the file, above the </Project> closing element, add the following <ItemGroup>:

     <ItemGroup> <Using Include="SadConsole" /> <Using Include="SadRogue.Primitives" /> <Using Include="SadConsole.Console" Alias="Console" /> </ItemGroup>

    This XML block adds the namespaces to every code file, automatically. This is optional, but most of the code provided in the documentation assumes these namespaces and types are imported.

  5. Save the file and close the XML editor.

Your project file should look similar to this, though the <TargetFramework> may be different (which can be net6.0 or above):

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <RootNamespace>SadConsoleGame</RootNamespace> <TargetFramework>net7.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" /> <PackageReference Include="SadConsole.Host.MonoGame" Version="10.0.3" /> </ItemGroup> <ItemGroup> <Using Include="SadConsole" /> <Using Include="SadRogue.Primitives" /> <Using Include="SadConsole.Console" Alias="Console" /> </ItemGroup></Project>

Root screen

The startup code, which you'll write in the next section, designates the startup object, known as the "root screen." That object is a ScreenObject type, or any type derived from ScreenObject such as ScreenSurface. Create a new root screne:

  1. In the Solution Explorer window, right-click on the project and select Add > Class.

  2. Name the class RootScreen and create it. The code editor for the class is opened.

  3. Replace the generated code with the following:

    class RootScreen : ScreenObject{ private ScreenSurface _mainSurface; public RootScreen() { // Create a surface that's the same size as the screen. _mainSurface = new ScreenSurface(Game.Instance.ScreenCellsX, Game.Instance.ScreenCellsY); // Fill the surface with random characters and colors _mainSurface.FillWithRandomGarbage(_mainSurface.Font); // Create a rectangle box that has a violet foreground and black background. // Characters are reset to 0 and mirroring is set to none. _mainSurface.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, Mirror.None); // Print some text at (4, 4) using the foreground and background already there (violet and black) _mainSurface.Print(4, 4, "Hello from SadConsole"); // Add _mainSurface as a child object of this one. This object, RootScreen, is a simple object // and doesn't display anything itself. Since _mainSurface is going to be a child of it, _mainSurface // will be displayed when RootScreen is either the starting screen or somewhere in that collection of objects. Children.Add(_mainSurface); }}

Program startup code

  1. In the Solution Explorer window, double-click the Program.cs. This opens the code editor.
  2. Replace the code with the following:
using SadConsole.Configuration;Settings.WindowTitle = "My SadConsole Game";Builder gameStartup = new Builder() .SetScreenSize(90, 30) .SetStartingScreen<RootScreen>() ;Game.Create(gameStartup);Game.Instance.Run();Game.Instance.Dispose();

Press the F5 key to run your SadConsole program. You should be presented with the following screen:

Get started with Visual Studio | SadConsole v10 (3)

Next steps

Now that you have the project created and working, check out the Get Started tutorial series.

Get started with Visual Studio | SadConsole v10 (2024)

References

Top Articles
Reconsidering the Faith of Hebrews 11
A Course of Lectures on the Early History and Early Conceptions of the Ecclesia and One Sermon - Christian Classics Ethereal Library
Cappacuolo Pronunciation
Busted Newspaper Zapata Tx
Walgreens Pharmqcy
T Mobile Rival Crossword Clue
Craigslist Mexico Cancun
Directions To Lubbock
What's New on Hulu in October 2023
Ktbs Payroll Login
Cranberry sauce, canned, sweetened, 1 slice (1/2" thick, approx 8 slices per can) - Health Encyclopedia
Tokioof
Signs Of a Troubled TIPM
The Connecticut Daily Lottery Hub
Industry Talk: Im Gespräch mit den Machern von Magicseaweed
Labor Gigs On Craigslist
Overton Funeral Home Waterloo Iowa
Google Feud Unblocked 6969
Katherine Croan Ewald
Busted Newspaper Fauquier County Va
Adt Residential Sales Representative Salary
Happy Life 365, Kelly Weekers | 9789021569444 | Boeken | bol
Drug Test 35765N
2021 Volleyball Roster
Two Babies One Fox Full Comic Pdf
Everything To Know About N Scale Model Trains - My Hobby Models
R/Airforcerecruits
Tamil Movies - Ogomovies
Sony Wf-1000Xm4 Controls
Kamzz Llc
Publix Coral Way And 147
Ofw Pinoy Channel Su
Frommer's Belgium, Holland and Luxembourg (Frommer's Complete Guides) - PDF Free Download
2487872771
Royal Caribbean Luggage Tags Pending
Upstate Ny Craigslist Pets
Mgm Virtual Roster Login
What Time Is First Light Tomorrow Morning
7543460065
Rage Of Harrogath Bugged
Riverton Wyoming Craigslist
Directions To The Closest Auto Parts Store
Sarahbustani Boobs
Powerspec G512
Senior Houses For Sale Near Me
Craigslist Mendocino
John Wick: Kapitel 4 (2023)
Xre 00251
Stephen Dilbeck, The First Hicks Baby: 5 Fast Facts You Need to Know
Blippi Park Carlsbad
Solving Quadratics All Methods Worksheet Answers
Les BABAS EXOTIQUES façon Amaury Guichon
Latest Posts
Article information

Author: Van Hayes

Last Updated:

Views: 6288

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Van Hayes

Birthday: 1994-06-07

Address: 2004 Kling Rapid, New Destiny, MT 64658-2367

Phone: +512425013758

Job: National Farming Director

Hobby: Reading, Polo, Genealogy, amateur radio, Scouting, Stand-up comedy, Cryptography

Introduction: My name is Van Hayes, I am a thankful, friendly, smiling, calm, powerful, fine, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.