Learn C# by Building a Simple RPG – Index

Giant Spider!
Mandatory Giant Spider!

If you want to write a Role Playing Game, but don’t know how to program, or just want to learn how to program in C#, then you’re at right the place.

These lessons will take you from a complete beginner, to being an author of a Role Playing Game, for free.

Now, this isn’t the world’s greatest game. In fact, it’s very short and kind of ugly.

However, as you create it, you’ll learn the most common C# programming practices and techniques. Then, if you want, you can improve the game, adding more features and your own special touch to it.


NOTE: One of the awesome students here created a PDF document of the lessons. You can get a copy of it here, or here. You can also download the source code files for the lessons here, or here. Thank you, Mark!



Lesson 00.1 – What is in these lessons?

Lesson 00.2 – General information about programming in C#

Lesson 00.3 – The parts of Visual Studio

Lesson 01.1 – Defining classes and objects for the game

Lesson 02.1 – Installing Visual Studio Express 2013 for Desktop

Lesson 02.2 – Building the solution for the game

Lesson 03.1 – Building the first screen

Lesson 04.1 – Creating the Player class and its properties

Lesson 05.1 – Creating objects from classes

Lesson 06.1 – Creating the remaining classes

Lesson 07.1 – Inheritance and base classes

Lesson 08.1 – Setting properties with a class constructor

Lesson 08.2 – Using class constructors with derived classes

Lesson 09.1 – Using your classes as datatypes

Lesson 10.1 – Creating collections of objects

Lesson 11.1 – Using a static class

Lesson 12.1 – Add the remaining UI controls

Lesson 13.1 – Functions, procedures, and methods

Lesson 13.2 – Creating functions to handle user input

Lesson 14.1 – Variables

Lesson 14.2 – If statements

Lesson 14.3 – Foreach loops

Lesson 15.1 – Getting random numbers for the game

Lesson 16.1 – Writing the function to move the player

Lesson 16.2 – Refactoring the player movement function

Lesson 16.3 – Functions to use weapons and potions

Lesson 17.1 – Running the game on another computer

Lesson 18.1 – Future enhancements for the game

Bonus lessons (enhancements to the game)

Lesson 19.1 – Scroll to the bottom of a rich text box

Lesson 19.2 – Use a calculated value for a property

Lesson 19.3 – Clean up the source code by converting foreach to LINQ

Lesson 19.4 – Saving and loading the player information

Lesson 19.5 – Changing dropdown default values

Lesson 19.6 – Increase maximum hit points when the player gains a level

Improving SuperAdventure’s code quality by refactoring

Lesson 20.1 – Refactoring the SuperAdventure program

Lesson 20.2 – Binding a custom object’s properties to UI controls

Lesson 20.3 – Binding list properties to datagridviews

Lesson 20.4 – Binding child list properties to a combobox

Lesson 20.5 – Moving the game logic functions from the UI project to the Engine project

Adding a vendor to locations (with buying and selling items)

Lesson 21.0 – Plans for adding a vendor to locations

Lesson 21.1 – Adding a price to game items

Lesson 21.2 – Create the vendor class and add it to locations

Lesson 21.3 – Add a button and create its eventhandler in code, without the UI design screen

Lesson 21.4 – Completing the trading screen

Use SQL to save and restore player’s game data

Lesson 22.1 – Installing MS SQL Server on your computer

Lesson 22.2 – Creating database tables from classes

Lesson 22.3 – Creating the SQL to save and load the saved game data

Creating a console UI for SuperAdventure

Lesson 23.1 – Creating a console front-end for the game

Final refactoring (cleanup) of the SuperAdventure source code

Lesson 24.1 – Make the SuperAdventure source code easier to understand and modify

New game features

Lesson 25.1 – Select a random monster at a location


Share your personal, expanded versions of SuperAdventure here!

261 thoughts on “Learn C# by Building a Simple RPG – Index

  1. Hello again, Mr. Lilly,

    It has been a while since you last helped me in my endeavors to learn C# and programming in general. I don’t have any questions for you this time, but some news. 10 months after graduating with my BS in CS, I’ve finally managed to break into the professional field by landing a paid internship. I cannot overestimate how ecstatic I am. I’ve reason to believe that part of what put me over the edge of other potential employees (if they existed) was that I had demonstrative proof of having worked on a project of some sort. Among the coding examples I provided after the initial interview was the project I started after finding this site. Though there is no object-oriented programming going on in this position, several portions of the project either hinted at or was directly related to the skills deemed requirements, specifically knowledge of XML.

    I just wanted to let you know that you and your tutorials helped pave the way to my success. I know I don’t know you very well, but I admire your work and your willingness to teach.

    I don’t believe I can thank you enough.

    1. Congratulations! That is great news!

      You also learned two important career lessons, very early on. Invest time to improve your skills (or learn new skills), and have something you can demonstrate to employers. Many programmers wait for their employers to “give them an opportunity” to learn something new. A few programmers “make their own opportunities”. They experiment with new technologies, and post their code samples online. When a new position comes along, it’s easy to guess which type of programmer will be selected for it. Even if you only put in a few hours every week, you can see some amazing results over the years.

      Best wishes to you, in your new career.

  2. I found this tutorial incredible and worthwhile – so thank you for the lesson. Do you have any other tutorials that would show basically the same thing but with graphics?

  3. Hi Scott,

    This is really a great tutorial and easy to follow. I finished the basics (upto Lesson 16.3) and tried to run the game but I am getting this exception message:

    An unhandled exception of type ‘System.TypeInitializationException’ occurred in SuperAdventure.exe

    Additional information: The type initializer for ‘Engine.World’ threw an exception.

    This occurs at Line 25:
    24 _player = new Player(10, 10, 20, 0, 1);
    25 MoveTo(World.LocationByID(World.LOCATION_ID_HOME));
    26 _player.Inventory.Add(new InventoryItem(World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1));

    Can you help me resolve this exception?


        1. The Quest class is missing the initialization of the QuestCompletionItems property. Look at line 26, in the constructor from Lesson 10.1, to find the missing line.

          I also noticed there are no eventhandlers for the movement buttons. So, the player cannot move.

          To fix this, you can open SuperAdventure in Designer (graphic) mode, click one time on each movement button (do not double-click on them). Look in the “Properties” section of Visual Studio (the lower-right corner). Click on the lightning symbol, to see the events. Look for the “Click” event, and select the right movement function for each button (for example, “btnNorth_Click”, for the “North” button). This is what the “Properties” section looks like:

  4. Hey Scott,

    First of all this tutorial has been great so far I’m loving it!

    But I’ve come to a stand-still, I can run the program without errors but It doesn’t seem to be generating the quests or monsters in the game and I can’t for the life of me figure out why?

Leave a Reply

Your email address will not be published. Required fields are marked *