I recently published this guide for beginners to learn C# by creating a small role-playing game.
It’s a good place to start. However, as a game, it’s pretty limited in what it does. There are no spells or skills, there’s only one type of potion, there aren’t any graphics, and much more is missing.
Now, I’m going to build a more robust game.
The program is a Windows Form app, to run on the desktop, the same as the tutorial.
Right now, the solution file contains two projects; the UI project and the Engine (named ScottsRPGEngine, ’cause that’s how I roll).
One big difference from the tutorial is that all the game logic will be in the engine project in this project. In the tutorials, I showed how to move logic from the code behind the UI form, but there was still a lot of logic in there. Now, it will be in the proper place.
Also, I’m handling communicating from the engine to the UI differently. Now, I raise events in the engine code, and the UI watches for them.
So, when a monster attacks a player, you make a call to the player object’s SubtractHitPoints method. Whenever the player’s CurrentHitPoints changes, a CurrentHitPointsChanged event is raised. The UI watches for that event and knows to refresh the hit points value on the screen when it sees it.
There won’t be any video tutorials this time. A lot of what I’m going to do will be sort of experimental. So, there will probably be lots of parts of the program that change frequently, based on test results or how I feel the change impacts the quality of the program.
However, I am making the source code available for you to use, under the MIT license. It’s here on GitHub.
Go to the GitHub page and “watch” the project, to follow along with the changes.