Text Game Design Flaw

Started by
1 comment, last by Moonshoe 15 years, 9 months ago
So I'm making text base game and I wanted to implement a feature where when you kill a monster in a certain room it stays dead. As of now if you walk into a room, fight a monster, kill it, leave the room, and come back the monster would have miraculously respawned. I tried a few methods of implementing the feature by adding a bool to the structure that makes the rooms as well as the monster class but it ends up making every monster dead in every room. I believe the problem is the I have an external text file to read the data from and I read all the data into variables in tRoom. This really makes the rooms a set of variables and not very "tangible" or "individual" My only solution to this would be to make a room class instead of a structure so each room could have its own monster and thus I could kill or respawn the monster with a simple bool. Here in lies my problem. Making a room class would require me to take an axe to pretty much all of the 400 lines I've already written and I just wanted to know if there was a better way before I went along and destroyed it all, haha.
Advertisement
IMO having it as a class from the start and vectorising that class would have saved you a lot of headache.

Your issue is inherited from the way that your calling the rooms, when you are referring to your external file i would assume that your not updating that file when the creature is killed? then when you move from room 1 to room 2, it is pulling room 2's information directly from the file. Move back to room 1 where the monster was killed and reload the room from the file to find it still alive.

As a solution if you load all the rooms information into memory when you start the program into an array, vector, list, whatever... and have the rooms be referenced to in memory and not from file each time. If you want to save, you have it output the data in memory to a file in the same format that you have pulled it in from the starting file.
Try this: When the player decides to leave the room, update the file with the room/monster's info, then allow the player to leave.

This topic is closed to new replies.

Advertisement