Text based adventure game Microsoft Visual Studio c#

Started by
15 comments, last by alexfeetham 10 years, 4 months ago

Great progress Alex, congratulations!


In essence all I need to do to have working navigation is add rooms to the game and their respective exits, before I do that though [...]

If you haven't already done so I'd add at least two or three rooms and exits to the game to at least verify everything is really working correctly. It shouldn't take you long, and you can then proceed to add all those other cool ideas, but if you add all the other features first you might have more trouble tracking down any problems with your existing code. It's always good to verify that what you've done seems to be working correctly before proceeding. smile.png

- Jason Astle-Adams

Advertisement

Already done that =) Added a few filler rooms to test the code works, so far everything works fine. Had a few little issues early on that I fixed easily enough.

Well I feel that C# is beating me right now. here's my progress so far.

Done:

- Method for creating rooms in the game and adding exits to them.

- Game loop

- Intro including storing character name as string (dunno if i'll use it again its more a hello so and so your adventure starts here type thing)

- Put the level list into the room class rather than having it in the program class (was easier than I thought)

- Put a few tester levels in to make sure everything works and navigation is possible

- Basic commands such as "help", "go", "quit" all working as intended.

To Do;

- Add items in (currently working on and its frustrating)
- Add inventory display to the game

- Add Player health to the game (shouldn't be hard to do to be honest, just gonna do it later)

- Add Traps to the game that have can affect player health

- Add monsters that need to be defeated to progress (will add weapons, easy once items are in)

- Finish the game!!

My first idea for adding items in was using a method within a separate class as I did with the rooms to list the items in the game and link them together. I can list them but i'm currently working out how to actually link them together e.g. If the players writes the command "take item" it will look to see if there is an item linked to this room and if so display that the item has been picked up and also write that it has been taken. I can't seem to link a level to an item (from class to class).

Also this is due in next week so I have decided I will hand in the bare minimum required to pass the criteria and keep this as an ongoing personal project. I want to eventually have this as a finished game that I can keep adding to =P

Starting object orientated programming next month so im sure a lot of this stuff will become clearer on how I should approach them.

Cheers for any help that anyone has given so far it's been much appreciated.

TL;DR?

Keep in mind one of the most important and fundamental rules of games(and programming as a larger profession) is to seperate data from code. Using that line of thinking we can go, well in the text adventure game what is data? Clearly the rooms themselves are data, the information about their exits and description and such, also data.

Usually when people start off with games they tend to do the "hard code" approach, i.e. you make a function that displays the text for one room and you write the description right into that function. While it works, its a lot of wasted code whether you're doing functional or OOP. Sure you could make a function for every room but the rooms are all so similar, instead why not consider the things that the rooms share to be data and have the function operate on that plain data.

Now you probably already know this quite a bit but I'm more emphasizing the principle behind it, because it basically works for everything you're going to do. Example being rooms, what might you do in a room? "look?" well what does that do really? Thinking of it logically we can deduce the look function probably needs to grab the room title, its description, and check its exits to display which exits are open to you. So how can we do that? Well we'll need a collection of rooms for one, as was stated above you can use something like an array or a collection to contain a bunch of "room" data objects. What else do we need? Well we have to know which room the character is in so we can grab its information, there's a few ways to do that as well. For instance you could create a number index system, i.e. your player has a variable saying it is in room 7 and room 7 either is an index into the room array or maybe an id number that you search for. You also could just have a "room" variable for the player object that will be a reference to the room they are currently in.

Sorry if that was a lot of text, since this is homework I don't want to give too much concrete examples, but if you think about the logical deconstruction of the "look" function, you can apply that to other things, items, monsters, doors. It's all basically the same.

Well as of tomorrow (provided I finish it up in time to a good standard) this becomes a personal project =) So no time restraints can just change it to my hearts content =D

Congratulations on completing the project sir. :)

I'd also like to say that this thread was much better than many of the other homework help threads out there. So thumbs up there as well.

- Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

Let me guess Eck you get a lot of folks just expecting you to hand them the code on a plate? =P

This topic is closed to new replies.

Advertisement