Advertisement

Help! Beginner creating a game! =)

Started by November 16, 2000 08:04 PM
12 comments, last by dos_programmer 24 years, 2 months ago
I am using Turbo Pascal 7. I know, I know.. I''ll be learning C/C++ eventually.. anyway, I started writing a text adventure and it is harder than I expected! =( does anyone know of any good tutorials/articles on writing a text adventure in some language that is NOT specifically tailored to interactive fiction programming?? (such as Hugo, TADS, etc) I want to do it in a real language. Thanks for your time.. please email me if you can.. dos_programmer@yahoo.com / shadow
There''s too much blood in my caffeine system
Somewhat off topic, but Turbo Pascal''s big brother is Delphi. I think you will find it both easier to maintain the text and do the actual game using it.
Keys to success: Ability, ambition and opportunity.
Advertisement
I actually have Delphi 4. I am going to get a book on it for x-mas I think. But then I''ll change my handle to win_programmer =)

so is Delphi that good? Do you know of any books on Delphi? About learning it? Maybe SAMs has a book.. I''ll check that out. and maybe game programming with Delphi..?

thx for your time,

/ shadow
There''s too much blood in my caffeine system
I would suggest going through the programming guide in the help system for Delphi. Also check out the links on the Inprise website to other websites dedicated to Delphi. There is a lot of good information out there for all levels of both programming in general and delphi specific experience. If you are on a limited budget these are all free. They should give you a good idea of what books you should buy. Otherwise Barnes & Noble or Amazon are a good place to see what is available.

A word of warning on game programming books is in order. Most are for graphics programming. Most only touch lightly on what you need. A general book such as Object Oriented Analysis and Design by Grady Booch will most likely do you more good for what you want to do than most game programming books. Also books on relational databases in general or database programming in Delphi specifically will help.

I would say overall just place yourself in the players position. The first thing they want to do is enter the world so you need a world. The world is collection of locations. Locations have relationships to each other. The biggest one is whether the player can move directly from one location to another. Closely related to that is how they move to the connected locations. Within a database you basically have a world table listing all locations. You have another table listing all exits from each location and the location each exit takes you to. With a database all you need is to know which location is the starting location. From then on you just keep track of where the user moved to. You give them a option for listing all the exits saying perhaps "You see the town square to the north". They can then say "walk north" and you use the exit table to find the north exit from their current location and replace their current location with the new location. So now you have a world they can move around in. After that you just pick one new thing you would like them to be able to do and add that. An example might be placing items in the world so you have an items table and a table tying items to locations. You add a commands so they can list the items in a location and examine items. The entire game may be complex, but it breaks down into a long series of simple tasks. Don''t worry about how you do everything, just worry about how you do the next thing. Until you have a world placing items in the world isn''t very important. Until you place items in the world picking them up isn''t very important. Until you can pick them up having an inventory isn''t very important.
Keys to success: Ability, ambition and opportunity.
Good advice LilBudyWizer, Makes sense. I think we would all do well to program in that fashion. There is no need for input, if there is no output. There is no need for a bag, if there is nothing to put in it. There is no need for exits, if there are no entrances... Sounds kind of like master/student stuff... Good words, man.
farmersckn
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
I don''t really get your point. Beginning programmers often get lost in the complexity of their final goal when everything you have to do is just one small step from what you already did. Perhaps you write 30 lines of code at once, but I write one and then the next. Let me guess, you write a 100,000 lines of code before you test jack. I suppose you also just add code randomly without any thought to actually having any functionality until you are done. No wait, I have it. You don''t code jack and you just run around flaming people trying to help someone instead of offering any useful advice. If you want to impress me give better advice.
Keys to success: Ability, ambition and opportunity.
Advertisement
Then again I might not have taken it wrong. Which if I did I apologize for that. I''ve seen a number of posts by someone flaming people for asking questions so I might be a bit quick to jump to conclusions.
Keys to success: Ability, ambition and opportunity.
Actually, I did do that.. being a beginner, I lost sight of what I was currently working on (linked lists for descriptions of each room), instead envisioning the end result, did not comment or test, and I had lots of problems with the program once I thought I had it all worked out up to that point =) it took me all night to fix it. at least now I can walk around in my textual world..
There''s too much blood in my caffeine system
This probably wont help you but its pretty funny. When I was first learning to program, my language of choice was QBasic. So one day I decided I wanted to write zelda, assuming it would take a couple of days (This is with graphics, mind you). I sat down the first day and programmed in some sprite graphics, such as link himself, heart pick ups, walls, trails, grass, etc. Everything was going fine (besides the fact that it took a half hour to type in one little sprite because I was using the color codes in arrays and typing them all in by hand) until I made link able to move. Suddenly I learned about such things as collision detection, having to rewrite the tiles that link passed over, and the fact that I could walk link right off the edge of the screen. Suddenly I realized that this was much more complicated than I thought. To make a long story short, I ended up programming in three screens, one with a wireframe 3d house, one with an octorok (those little spikey things that shoot rocks at you) with minimal AI, and a statue that shot a laser beam at you whenever you passed in front of it. Then I deleted it.
the moral of the story: Start simple (such as my connect4 game, check it out on the GDS)
(I know this isn''t written very well, but hey, Im a product of the American education system, so sue me)
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
dos_programmer,

I''m not sure how you are getting things into your linked list. I would suggest putting everything in text files. You would have one file that has all your rooms defined with a short name to use to identify it in other files. One of the other files would be a pair of room ids. Then load the list of rooms into your linked list. Then on each room have a linked list of rooms that are adjacent. When you load the list of adjacent rooms replace the room ids with pointers to the actual entries in the linked list of rooms. The only actual use of a linked list you should make is taking the first room as the starting point and while loading data.

To speed the search for rooms, and more importantly managing the information as you edit it, when things get large you might want to assign each room an area. Then you identify a room by an area/room pair. You can put each area in a seperate file and have a file defining each area including the file that contains the definition of the area. Exits from a room to a room in another area is handled by flagging area exits and just naming the area you are exiting to. This is because that area may not be loaded yet so you can''t find the room. You load the list of areas first so you can resolve that as you load an area. Once all the areas are loaded you load a list of area exits that lists all the areas you can reach directly from each area. This would include the room within the area the exit is from and the room that is the enterance to the other area. You resolve those to actual pointers as well. When you encounter a room exit that exits an area you call the area give the rooms address and the area you are exiting to. It will use that to find the room you are entering.

I assume you are using object oriented programming for this. With the example I gave you would have an areas object that is the list of areas and an area object that represents a single area. The area object has a rooms object that lists all rooms in the area and is made up of room objects that define each room. The room object has an exits object that lists all the exits for the room that is made up of exit objects that define an individual exit. Derived from an exit object is an area exit which is a special kind of exit. You might also derive a door exit that has to be opened to use the exit and from there a locked door object that must be unlocked to be opened. You would have member function for use and useon on the exit. Using an exit takes you to the next room. Using an area exit takes you to the next room in the next area. Using a door exit opens it unless it is already open which then takes you to the next area. Using a locked door does nothing, unless it is unlocked which opens it, unless it is already open which takes you to the next room. If it is locked you have to use a key on it to unlock it.

I would wrap everything so you load it by just creating an areas object and telling it to load a file. It would load the area file by creating an area object and telling it to load an area and continue doing that until it reached the end of the file. A similar process would be done for the rooms and so on. The main thing to watch out for is the derived objects. You have to identify which type of object you have from the file before you can create the correct object type. One way you can do this is by extending the line at the end. You can then always load the base object and if you are not at the end of line or file promote the base class to a derived class and continue loading. If multiple classes are derived from the base class then you need a field after then end of the base class saying which one it was. As an example if both doors and area exits are derived from exits then a field saying area or door. You then create an area or door exit from the exit you have and continue loading. The alternative is putting it at the start of the line which makes it easier to see what type of object you are dealing with while editing, but a little harder to actually edit.

I think if you use a lot of files you will find it easier than using single large files. Since search text files is a chore this effectively gives you an index. You can also use directories to break things up. Performancewise it won''t do much unless you have an extremely large number of files, but it will make it easier on you long before that. With Delphi you can easily put everything in a table, define an index and search for what you are looking for. As an example you could have a rooms table with the area/room as a key. Then as you load an area you search for a partial key of area. You can also create GUIs to make it easier to edit the content, navigate the links and see the overall structure at a glance.

CHollman82,

Some would take that as a case for where a design was needed in advance, but I view that as an example of where a design in advance is difficult to do. By digging in and trying it you learned what you needed to do. Some could argue that you could of read some books to figure that out, but nothing teachs as well as experience. One of the first things I learned in programming was that seldom does it really work as I read it. Generally what the author wrote was precisely true, but the assumptions I made as to why it was true were wrong. Also it is often the mistakes you made that lead to the greatest understanding. Hehe, divide by zero exception, so that is why they had that if statement checking if two variables are equal before the function call. They must divide by the differance of the two.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement