Welcome to my latest programming series – Rogue C#!
This is a demonstration of Microsoft’s C# programming language that I’m developing right here on ComeauSoftware.com. In these articles, we’ll work through the process of creating a role-playing game (RPG) in C# based on the classic game of Rogue. Throughout the chapters, I’ll show you the code and explain the ideas involved so you can follow along and customize your own roguelike game.
On this page, you’ll find links to all the chapters along with supporting information, resources and updates on the progress of the project itself.
Download the Code
The latest code for the project can be found on Github.
Table of Contents
View the latest chapters by selecting the Rogue C# Series category from the categories list or start from the beginning in the Table of Contents below.
- New Tutorial Series – Rogue C#An introduction to the Rogue C# series in which we’ll be designing a roguelike game closely based on the original Rogue and exploring how an application is designed from start to finish.
- Choosing a Programming LanguageThe question of what programming language to learn is a common one for beginners. Here are a couple things to consider when starting out.
- Writing the Program RequirementsDetermining the requirements for a program is an important first step in writing any software. Detailed requirements form an outline and direction for development.
- Working with ASCII Graphics in C#The original Rogue game relied heavily on ASCII graphics. This chapter is an overview of ASCII and Unicode and how it’s still used.
- Rogue C# – Creating the Game ProjectEvery program has a starting point and ours will begin with the creation of the Windows Forms project which will be the basis of our game. In this chapter, we also look at the basics of C# and .NET.
- C# Form Controls and PropertiesVisual Studio provides a wealth of controls that you can use in Windows Forms apps including buttons, text boxes and combo boxes. In this chapter, we’ll add a few basic controls to the project to display the game output.
- Rogue C# – AlgorithmsAs we start writing the code to generate the dungeon maps, we need a solid algorithm that will reliably create rooms and link them together.
- Rogue C# – Working with Classes and ObjectsObject Oriented Programming (OOP) is an important concept to understand for programmers of any language. In this chapter, we look at the basics of OOP and add the MapLevel class to our project.
- Using Constants in C#Constants enable us to store values that will be used in the program and give them context within the code. Constants will be used heavily in our roguelike game and this chapter shows how they can be used to construct the map.
- Class Properties and ConstructorsProperties and constructors are basic elements of C# classes and this chapter shows examples of how they’ll be used to describe and create maps in the program.
- Creating Roguelike Map RoomsRoguelike maps are made up of a network of rooms and the algorithm for creating the individual rooms is important. In this chapter, we’ll look at the use of loops and arrays in maintaining our network of dungeon rooms.
- Enumerations and Dictionaries in C#We need just a little bit of supporting code to actually plot the rooms on the map. In this chapter, you’ll see examples of enumerations and dictionaries in C#. You’ll also see a way to check a char value against many others at once.
- Concatenation and the StringBuilder ClassString manipulation is a common task in programming and C# has a couple of different methods for performing large numbers of edits to a selection of text. In this chapter, we’ll compare them and see how efficient the StringBuilder class actually is.
- Connecting Rooms on the Game MapCompleting the hallways on a roguelike map is one of the most challenging parts of the game and it goes back to the importance of the right algorithm that will teach the computer to do what you take for granted.
- Rogue C# – Verifying the Game MapWhat do you do when no algorithm seems to work without problems? In this chapter, we’ll see how not every problem is solved in a straight line and how some can be solved in phases.
- Rogue C# – Building the Class StructurePrograms often use multiple classes that work together to provide structure to the program. In this chapter, we’ll expand our roguelike with the new Game and Player classes.
- Rogue C# – Gold RushAt this point, our game can generate a random map and there are classes to control the game itself and define a player. Now I want to spread some gold around the rooms for the player to collect. In the process, we’ll be making some improvements to how the program handles Random values.
- Responding to Key Events in C#One of the recognizable features of the original Rogue game was the long list of key commands that the player used for all actions, including eating, searching and using objects. Now we’ll see how we can implement those in our own roguelike.
- Rogue C# – Wandering the MapNow that the program can respond to different keys, it’s time to let the player start wandering the map. This chapter shows one way of doing this while making sure the player stays within the right boundaries.
- Searching a C# Array with LINQLINQ is a powerful feature that enables the program to search collections of data in much the same way that SQL searches databases. This chapter shows the basics and how they can be used in the program.
- Rogue C# – Leveling UpRogue is a game in which the player moves through many levels to their ultimate goal. In this chapter, we add this feature to our own game.
- Coding the “Fog of War”The “fog of war” is an important feature for adding challenge and mystery to a game as the player must gradually discover new territory and whatever surprises are there. It’s also a challenging feature to code.
- Rogue C# – Hidden DoorwaysHidden doorways and passages are one of the challenges in many games and Rogue is no exception. It makes the game a little more challenging and stretches out the game experience, too. In this chapter, we’ll see how to add hidden doorways to our own roguelike.
- Rogue C# – First Project ReviewIn this chapter, I want to review what we’ve done so far in this series to show how everything has contributed and where it’s going from here so you’ll have a better understanding of how an application grows.
- Rogue C# – Turns and CheatcodesRole-playing games are often turn-based; your character performs an action and then all the other characters and opponents get their turn. For this reason, managing the turns is essential to the game and that’s what we’re looking at in this chapter.
- Rogue C# – The Inventory ClassNow we need inventory collection in the game, starting with food. We need a system in place for collecting and managing not only food but all the other collectibles such as armor, weapons and potions which often have different requirements.
- Rogue C# – Building the InventoryThe inventory items have a complete cycle throughout this game, depending on the item, and each step has to be coded so that the inventory exists and is managed just like inventory items would be in real life. Every part of the program will be affected in some way.
- Rogue C# – Displaying and Selecting InventoryIn addition to collecting inventory, the player needs to be able to view their inventory and manage its contents so they can have the specific items they need. We also need a way to display other screens and come back to the map when needed.
- Rogue C# – “A mango a day …”Food is one of the most important items that you look for on the map so it’s appropriate that food be the first inventory item that we implement in our roguelike game. In this chapter, I’ll demonstrate how the player’s level of hunger can be managed and write the function that will allow the player to consume food and keep going.
- Rogue C# – Speed it up!Fast Play mode lets the player zip around the map without having to press the direction keys for every space but each space still equals one turn. In this chapter, we code for that and a couple other odds and ends.
- Rogue C# – Inventory RevisitedBefore we can introduce monsters and fights to the game, the player needs some items such as weapons in inventory. It’s time to test some of the theory the Inventory class is built on.
- Rogue C# – “Here there be monsters.”It’s a bit lonely in this dungeon game so it’s time to add some monsters and there’s a lot more to it than you’d think. In this chapter, I detail some of what’s involved in adding opponents to our roguelike.
- Rogue C# – Building the Monster ClassNow that we have some requirements for the monsters, it’s time to build the class and add a few new guests to the dungeon. As always, building the class requires some serious attention to detail.
- Rogue C# – The Monster ShuffleEvolution is often a difficult process and our program is definitely evolving. In this chapter, we bring the monsters to life and deal with a major refactoring of code as the need to store data increases.
- Rogue C# – The Monsters Strike BackAfter cleaning up from the program refactoring, I decided to complete the programming on the player stats. Then things got real when the monsters started fighting back.
- Rogue C# – Building on the FoundationThe game has a solid foundation and now we start building on it. There are still a lot of features to finish and bugs to work out along the way, especially the individual inventory items that will help the player survive in the dungeons.
- Rogue C# – A Few Random UpdatesFor this update, I decided to knock out a couple of quick features – the Play Again feature and the spawning of new monsters mid-level. A couple of bugs got squashed along the way.
- Rogue C# – Adding Scrolls and PotionsComing back around to the inventory side of the game, I decided to add some extra variety to the available items, starting with the scrolls and potions.