1 C# Text RPG Project: Part 1 – toxia.net

C# Text RPG Project: Part 1

I say Day 1,  but I actually spent months planning this in my head and drafting class diagrams, but after all this time I finally felt ready to start!

I wanted to create a text-based RPG, (NOT an adventure game). I have chosen C# as the language and decided to go with windows forms rather than the DOS command line like traditional text-based games use.

Why text-based?
Creating a text-based game allows me to be creative with game content without having to employ graphics skills that I really don’t have.

Why Windows forms?
There are 2 main reasons for this: One is that games that rely on the command line are getting more and more phased out with each new release of Windows (most require DOS Box these days). The second reason is to unlock the potential that forms have for text based games, namely, the ability to view more than one element at time (eg; to check inventory, the screen would have to switch to inventory screen, not letting you view details of the room or battle you are in).

I spent today creating the UI and some of the Character side of the RPG engine.

This is the working class diagram of the character system, right now I can create a Player, Animal or NPC at will. Once the battle system is implemented, all objects derived from the Human class will have methods for dealing and taking damage based on their weapon and armor. Animals will also have similar methods based on their min/max damage.

But before the battle system can be implemented, the items and inventory hierarchy needs to be implemented and that is my next step.

As for the UI, here is the work in progress.

Very doubtful that this is what the finished product will look like, but you can see where I’m going with it.

Now for a peek at some code… I have written most of the UI related operations, including my own print methods.

As this is a Windows Forms project and not console based, prompting for input works a lot differently as the flow of control doesn’t just stop to wait for the user to enter something, it just sits there listening for key press enter, therefor I have had to create a heap of flags so the program knows what to do with the current player input, then turn the flag off, for example, this is the switch for the intro, after a user inputs text, it checks what mode the the game is in, if it’s in intro mode, it will run this:

After /new or /load is input, the game will change to PlayMode, meaning that when text is entered, it will run the switch statement for the PlayMode. The same is for BattleMode and InventoryMode. This is the best possible solution I could come up with.

Feel free to drop me a comment here for any questions or suggestions, I’d be happy to answer them, I have most of program structure either mapped out in my head or on paper. I also have a bundle of content of my own fantasy universe written in word that I’ve built up over the years which I’m going to unleash on this game once the RPG engine is complete.

I do have somewhat of a creative mind, but the only tools I’m able to convey it with are code and English!

Comments 4

  • Looks like you are really having fun with C# at the moment. The UI is very advanced for a text based game – I thought you would be doing a CLI only thing – and it’s a pity it’s not cause now you can’t set up a server that we can ssh into.

    Anyway :) looks cool either way. I can’t wait to try it and give you some feed back on it.

    • Despite being less powerful, CLI would be easier in a lot of ways, it’s just I don’t think CLI gaming has much more of a run the way Windows OSs are going… I would hate to create something that could only be played for a few years before it’s forever lost.

  • Hi, Im a beginner developer. Just happen to stumble onto site. Sorta working on first project so its sorta a fake game. I was wondering how did you get your inventory system to work?

    • He probably had the inventory in a class based from the main character, and just stored the items in there.

Leave a Reply