By default FlatRedBall templates display the FlatRedBall icon or the MonoGame icon depending on platform. This article discusses how to add icons to your project.
A Desktop GL application needs 2 files:
.ico - used to display the .exe icon
.bmp - used to display the icon on the Windows taskbar
To change the icon on your game's .exe:
Open the folder where your .csproj is located. This is the same folder as your Glue file (.glux)
Locate Icon.ico
Open the Icon.ico to edit it, or replace it with an existing .ico file. Note that the file must still be called Icon.ico.
If you have changed your .ico file you may still see the old icon in Windows Explorer. Windows caches .ico files so you need to clear the cache. For more information see the following link: https://neosmart.net/wiki/clear-icons-cache/ To change the icon in the taskbar and on the window:
Open the folder where your .csproj is located
Create or replace an Icon.bmp file
If not already added:
Add the Icon.bmp to your Visual Studio game project - verify that the file is in the root of the folder
Mark the Icon.bmp file as an Embedded Resource
For more information, see this GitHub discussion: https://github.com/MonoGame/MonoGame/issues/5411 Additional info for DesktopGL: https://github.com/MonoGame/MonoGame/issues/8035#issuecomment-1557429524 And... https://github.com/MonoGame/MonoGame/pull/8036
FlatRedBall Web games can be uploaded to itch.io. This guide provides a walkthrough for uploading your game.
You must first publish your game through Visual Studio before uploading it to itch.io. For more information, see the Distribution page.
Once you have published your build through Visual Studio, you should have a folder similar to the following image:
Open the wwwroot and create a .zip file with the contents.
Next, log in to your itch.io account and select the option to Upload new project.
Fill in your project's information, but be sure to set Kind of project to HTML.
Click the Upload Files option and select your .zip file that you created earlier.
Check the This file will be played in the browser option.
You can specify the resolution for your project. Typically you should have your project run at a multiple of your native resolution so that pixels draw correctly. If your game uses a smaller resolution for a pixel aesthetic, you may want to set the resolution at two or three times the native size.
For example, consider a game which is set to a resolution of 398x224:
You can set the game to render at 300% scale by setting the size to 1194x672:
FlatRedBall games are distributed similar to any other app for a given platform. In some cases (such as iPhone and Android), a dedicated store exists for distribution. In other cases such as PC games, distribution can be done in a number of ways.
The DesktopGL platform provides the most flexibility for distribution.
The easiest way to distribute your game is to package it in a .zip file. When you build your game in Visual Studio, the output window displays the location where the built files are located:
Note that if you are building your game in Glue, the output directory may differ. The location will be displayed in the Build tab when you build and run your game in Glue:
To distribute this game, navigate to the folder where the game is built, select all files, and zip them. You may want to exclude .pdb files, as they can increase the size of your zip file.
This zip file can be sent to others such as testers or friends.
To create a release build, switch your build configuration to Release. If you are linked against prebuilt .dlls or NuGet packages and you would like to include FlatRedBall release packages, see the Release Build page.
Verify that you can build and run your game.
Next, right-click on your game and select the Publish item.
Select Folder unless you know how to publish to the other options.
Once you finish publishing, you can zip the project.
To distribute a FlatRedBall Web project:
Open your project in Visual Studio
Switch your project to Release build
If you are linking FlatRedBall nuget packages, instead consider linking to FlatRedBall Source so you can build the engine in release mode. FlatRedBall nuget packages distribute in debug configuration.
Select Build -> Publish YourProjectName
If asked, select the option to publish to a Folder unless you are familiar publishing with the other options
Confirm the folder where you would like to publish, then click Finish
Click the Publish button on the Publish tab
Wait for your project to finish building
After the project finishes building, click the Navigate link.
The project can be uploaded to any location through FTP. For information on uploading to itch.io, see the itch.io distribution page.
This document is written for older versions of FlatRedBall (.NET 4.X) and for games which do not include the .NET runtimes. We recommend that you include .NET runtimes in your game to make it easier for people to play your game. Doing so prevents the Probing Path from working.
By default FlatRedBall games are built to a bin folder which contains the game .exe file, referenced .dlls, and content. If you plan on distributing your game as a .zip file, users may be overwhelmed by the number of files after unzipping.
This can be solved using the probing
tag in the app.config file. This guide shows how to use probing
to move your game's files into a data folder. Note for .NET 6 users - if your game targets .NET 6 and you include .dlls for .NET 6 so that the user does not need to install the runtimes, this method will not work.
First, we'll need to decide the name of the sub-folder we want to use for our libraries and data. A common name is data. To add this:
Open your project in Visual Studio
Open the app.config
file.
Add the probing
tag with the folder name as shown in the following snippet
The example above tells the app to look in a data folder for referenced libraries. Note that when picking a folder, you will want to pick one that doesn't already exist in your project's folder structure.
Now that the probing
tag has been added, the game will look in the data folder for any libraries. Note that the game will continue to look in the main folder as well, so you are not required to move the libraries and content into the data folder until you are ready to distribute your game. Once you are ready, you will want to move every file into the data folder except for the main executable and the config file. Make sure to include your game's content folder and any of the files/folders required by MonoGame such as the x86 and x64 folders.
Once the files have been moved, the only remaining files will be the executable, the config file, and the data folder.
At this point there are only two files left in the root folder, but we can further simplify the folder by hiding the config file:
Right-click on the .config file
Select properties
Check the Hidden property
Click OK
Now the config file will be hidden. Note that if your settings are to show hidden files you may still see the file (with a half-transparent icon).
By default FlatRedBall templates build the debug configuration. These templates are distributed with release and debug versions of the libraries being used in the project. Therefore, to switch between release and debug you should also switch which set of libraries you are referencing. The steps to switch between debug and release depend on whether the application is linking to prebuilt binaries or source.
To switch a DesktopGL template to release:
Open your project in Visual Studio
Change the configuration from Debug to Relese
Expand your project in the Solution Explorer, and expand the References item
Right-click on one of the FlatRedBall projects and select Properties
In the Properties window, find the location where the FlatRedBall library is located
Once the properties window is open, identify all of the libraries which are being being referenced out of your game's Libraries folder.
In the case of DesktopGL these are:
FlatRedBall.Forms
FlatRedBallDesktopGL
GumCoreXnaPc
StateInterpolation
Remove these references from your project by right clicking and selecting Remove
After you removed the references, right-click on your project and select Add Reference...
Click the Browse... button
Navigate to your project's folder. Select the Libraries/DesktopGL/Release folder
Add the libraries which were removed in the previous step from the Release folder
Click OK
If you are going to build your game in Debug mode, you should link Debug FlatRedBall .dlls. Similarly, if you are going to build your game in Release, you should link Release FlatRedBall .dlls. Mixing Debug and Release may result in compile errors, as FlatRedBall provides additional classes and members in Debug mode which code generation relies upon for improved diagnostics.
If your project links to FlatRedBall Source, then you only need to switch the configuration of your project:
All libraries should switch to release automatically.
FlatRedball games can be distributed on Steam with or without adding code to handle Steam integration. Steam integration can be added using the Steamworks.NET library. This includes support for achievements and responding to the Steam overlay being shown.
To add Steamworks.NET library to your project:
Go to the Steamworks.NET github releases page
Download the latest release standalone
Unzip the downloaded file
Link the Steamworks.NET.dll file in your project
If you are targeting .NET 6, use the 64 bit version.
If you are making a Desktop GL (.NET Framework) project, be sure to link to the x86 version as this version of FlatRedBall does not support 64 bit builds
Copy the steam_api64.dll or steam_api.dll file to the same folder as your game's .csproj (and .gluj) depending on whether you linked to the 64 bit version of Steamworks.NET.dll
Add the steam_api file to your project in Visual Studio and mark it as Copy if Newer so that the file ends up in your game's bin folder next to the built .exe.
Add your steam_appid.txt file to the folder where your game's exe is located.
When testing, be sure to have Steam running or else your tests won't work.
Once the Steamworks library is added to your project, you can interact directly with the library to award achievements and respond to the tab overlay being shown. If you would like to work directly with this library, you can find additional information on the Steamworks github page. The documentation is focused on Unity but many of the concepts apply. Alternatively, the following SteamManager class can be used to set up a project quickly. Note that this is provided to help get a project set up quickly. Future versions of FlatRedBall may provide more integrated solutions such as code gen:
The steam_appid.txt file is a text file which is added to the same location as your game's .exe file. It is a text file which should contain only your app ID (which is a 7 digit number at the time of this writing, but may increase to 8 or 9 digits in the future). Note that creating the file in Visual Studio may add a byte order mark which makes your file unreadable by the Steam api, so create the file as a plain text file through Windows Explorer.
To use the SteamManager:
Add SteamManager.Self.Initialize();
to Game1 constructor
Add SteamManager.Self.Update();
to Game1 Update
Add SteamManager.Self.Exit();
to Game1 OnExiting (you may need to manually override this method in your game)
Normally games should be paused when the Steam overlay is shown. Games which use GameScreen as their base class for all levels can respond to the SteamManager's SteamOverlayVisibilityChanged event by pausing. For example, the following code snippet could be used to pause the game:
Steam achievements are handled in two places:
The achievements must be defined in the Steam dashboard for your game
Achievement logic must be added to your game
If using the SteamManager, the second point is fairly easy to do:
Find the Achievements class in the code above
Follow the example achievement to create your own achievement. Note that this pattern requires access to the game data, such as the profile information which may have values controlling whether an achievement has been fulfilled
In game code, call TryApply on achievements which may be achieved in response to certain game events. You may choose to award achievements the moment they are awarded, or at certain points of the game execution (such as the end of a level)
For example, consider an achievement which is awarded when the player has collected all possible power-ups in a game. This may be checked in the collision function between PlayerList and PowerUpList as follows:
The TryApply method performs a local check for awarding before sending anything to Steam, so making these calls frequently will typically not cause performance problems. Of course, be aware of situations where the checking of an achievement requires time intensive checks, such as loading files from disk or performing a large number of calculations.
If your game uses .NET 6 or newer, then it can be published as a self-contained app which includes all of the .NET 6 runtime files. While this increases the size of your game, it enables your game to run on any machine regardless of whether .NET 6 runtime is installed. Furthermore, it allows your game to run on SteamDeck. To do this, first add the following highlighted text to your csproj under the PropertyGroup tag.
Once you have done this, you can publish your application using the dotnet publish command or you can grab the files from the bin folder that Visual Studio creates.