Infiniminer MonoGame Port Log

Description

If you’ve been around in the MonoGame discord lately, you may have seen me discussing recently porting the original Infiniminer game by Zachtronics from XNA 3.1 to (current) MonoGame 3.8.1.303. Thought I’d created a forum post here to track the status and log of the port development as I continue on

One of the reasons I took up doing this port was out of sheer curiosity. I had never done a XNA-to-MonoGame port before, let alone one from XNA 3.1. I also thought it would nice to have a more complex game such as this as an example repository for other to look at and see. This was also a large educational experience for myself.

Repository

The repository for the port can be found at https://github.com/AristurtleDev/Infiniminer There are two branches in the repository

  1. main: This branch is where all the MonoGame 3.8.1.303 port and future updates are added
  2. original: This branch contains the original source code for reference.

Current Port Status

Infiniminer has been successfully ported from XNA 3.1 to MonoGame 3.8.1.303 as a direct port. In it’s current state it is playable with no crashes or major known bugs. However, the port was done as direct and brute forced as possible, there are many things that need to be optimized or adjusted to get full performance out of the game.

The following is a list of know things that are either need optimizations or are broken

  1. DirectX version runs significantly worse than the OpenGL version. Current suggestions are in how the DynamicVertexBuffer instances are created so often. Need to look into optimizing this
  2. Server/Client networking code is using the initial Lidgren version 1.0 to make the porting simple. The network code needs to be updated to either Lidgren Gen 3 or something more actively maintained like LiteNetLib.
  3. Some users have reported that while playing there are occasional lag spikes that hit for ~1 second then go away. This is most likely caused by the issue mentioned above in number 1, however this could be related to the network code as well, so it is currently under investigation. fixed by @nkast in PR 14

Planned Features

The following are features and improvements I plan to add to the game once the issues listed above are all or mostly solved.

  1. Controller Support
  2. Rebindable Keybindings
  3. Fullscreen support and/or Independent Screen Resolution support
  4. Sprinting key for movement

As more features are thought of or suggested and approved they’ll be added to this list.

3 Likes

Pull Request #3: Created seperate DesktopGL and WindowsDX platform

https://github.com/AristurtleDev/Infiniminer/pull/3

  • The project has now been reorganized so that there are separate clients for a DesktopGL build and a WindowsDX build. This is so it would be eaiser to test between the two for optimizations since the WindowsDX build seems to perform significantly worse than the DesktopGL version.

New project structure now looks like this

+---Infiniminer
|   +---Infiniminer.Client
|   +---Infiniminer.Client.DesktopGL
|   +---Infiniminer.Client.Shared
|   |   +---BloomEffect
|   |   +---Content
|   |   |   +---04b_03b
|   |   |   +---04b_08
|   |   |   +---blocks
|   |   |   +---icons
|   |   |   +---menus
|   |   |   +---sounds
|   |   |   +---sprites
|   |   |   +---tools
|   |   |   \---ui
|   |   +---Engines
|   |   +---StateMasher
|   |   \---States
|   +---Infiniminer.Client.WindowsDX
|   +---Infiniminer.Server
|   \---Infiniminer.Shared
\---Lidgren
    +---Lidgren.Network
    +---Lidgren.Network.Tests
    \---Lidgren.Network.Xna

Common Client code, include the Content files were moved to Infiniminer.Client.Shared. The DesktopGl and WindowDX projects both reference the content from there as linked content.

Pull Request #4: Restored original title screen

https://github.com/AristurtleDev/Infiniminer/pull/4

  • Restored the original title screen. Nothing against wideshanks new title artwork that was added, just prefered the original artwork. Will look into making this a client setting choice on which artwork to use

Lots of recent updates, all thanks to @nkast
Below are the most recent changes in the port that he has contributed too.

Pull Request #8: Fix Threading

https://github.com/AristurtleDev/Infiniminer/pull/8

Thread.Sleep(1) was changed to Thread.Sleep(0)

If the value of the timeout argument is Zero, the thread relinquishes the remainder of its time slice to any thread of equal priority that is ready to run. If there are no other threads of equal priority that are ready to run, execution of the current thread is not suspended.

Pull Request #9: Fix FPS Counter

https://github.com/AristurtleDev/Infiniminer/pull/9

This updates the FPS counter to accuratly display the FPS. The original method used was just counting the number of elapsed frames and dividing it with the total seconds passed in the game which gave inaccurate results.

Pull Request #12 Remove: Infiniminer.Client.Shared.Program.cs

https://github.com/AristurtleDev/Infiniminer/pull/12

Since each platform has it’s own entry point, the unused Program.cs was removed

Pull Request #13: Move shared content into shared folder

https://github.com/AristurtleDev/Infiniminer/pull/13

Previously each project type (DesktopGL and WindowsDX) had a seperate Content.mgcb that both referenced the same assets. I was under the assumption that the /platform flag in the Content.mgcb is what the mgcb used when building content. However the MonoGame.Content.Builder.Tasks.targets actually overrites that value based on the project type being built, so separate Content.mgcb files are not needed

Pull Request #14: Create SamplerStates during initialization

https://github.com/AristurtleDev/Infiniminer/pull/14

Creates a cached SamplerState during initilization instead of a new one each draw frame. This improves performance and GC pressure. Thanks again to @nkast for all of this work

2 Likes

Version 1.6 Released

https://github.com/AristurtleDev/Infiniminer/releases/tag/version-1.6.0

This version adds initial controller support to the game. Right now, controller support is only when playing the game itself. The next update will overhaul the title, sever select, team select, and class select screens to add controller support to them as well. For now, they still have to be navigated with keyboard/mouse.

Pull Request #17 by @nkast

https://github.com/AristurtleDev/Infiniminer/pull/17
Fixes bloom effect

1 Like

THANK YOU SO MUCH

This is really going to help out for my video game i’m working on.

I am working on a 3D voxel game I have a LWGJL but I need a voxel game engine in C# for Xbox support

1 Like

Hey i’ve been trying to compile this for weeks but every time it fails. The server builds fine but the game.

/home/ksportalcraft/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): error MSB3073: The command “dotnet mgcb /@:”/home/ksportalcraft/Documents/Infiniminer/source/Infiniminer/Infiniminer.Client.Shared/Content/Content.Shared.mgcb" /platform:DesktopGL /outputDir:"/home/ksportalcraft/Documents/Infiniminer/source/Infiniminer/Infiniminer.Client.Shared/Content/bin/DesktopGL/Content.Shared" /intermediateDir:"/home/ksportalcraft/Documents/Infiniminer/source/Infiniminer/Infiniminer.Client.Shared/Content/obj/DesktopGL/net6.0/Content.Shared" /workingDir:"/home/ksportalcraft/Documents/Infiniminer/source/Infiniminer/Infiniminer.Client.Shared/Content/"" exited with code 8. [/home/ksportalcraft/Documents/Infiniminer/source/Infiniminer/Infiniminer.Client.DesktopGL/Infiniminer.Client.DesktopGL.csproj]
0 Warning(s)
1 Error(s)