Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Save Point Question..

Author
Message
LordDario
22
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 2nd Jun 2005 04:36
Im working on a small rpg text based game and had a question about loading a saved game. I know how to save variables and arrays and then reopen them but what I don't understand is how would you save information on where exactly you left off in the game so that when you load it will go right to it. Example:

You just gained a lv and a bunch of your stats were raised. You go to a save point in town in save, and then you turn off the game. When you come back to play it you load the game and all your new stats from your lv increase is loaded however how does it know to return to where you saved as if you never turned off the game?

Dario
KYP
20
Years of Service
User Offline
Joined: 5th May 2005
Location: 01110000
Posted: 2nd Jun 2005 09:24
uhhhh.... im not really sure, but you could problably save your position into an array....

program 'till your butt falls off, and never give up.
LordDario
22
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 2nd Jun 2005 10:06
i might of not made my post real clear. What i meant is how would i kind of put a pointer of where my code last left off. Like lets say the next line of code right before i saved was a message that said "welcome to the arena" when i load the game how would i make it know to go to to that section of code.
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 2nd Jun 2005 12:21
well you can use the goto command to go to where you want to go

NARUTO IS THE NINJA.......not really
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 2nd Jun 2005 22:33
LordDario,

I believe that the text(s) you wish to display like, "welcome to the arena" should initially be constants. Make one array in your program, fill it with these lines of text. In your code, use a single variable to know what text, if any was last being displayed(for loading purposes) and also for what text should currently be displayed(for current gameplay, even before a load). When a game is saved, save this variable also. When the game is loaded, load it also. To make myself clear, the variable should be used like below:


Another way to do this, is to simply save the current string of the text that is being displayed, at the point that the game is saved. When you read the file to load the game, as should be in the same order it was saved, then the program knows what text to currently display. Both of these methods will work fine. However, there is no way to tell your computer to go to a certain spot in your code, except by "hard-code", which you cannot load information as "hard-code".


+NanoBrain+
LordDario
22
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 3rd Jun 2005 00:03
Heres the method i was thinking of doing it. Since i want to allow it where you can pretty much save any time you want, I was thinking of having a bunch of flags which could jump me through code. For example lets say i have 2 locations in my game the beach and the forest. I would make both those areas their own little sections of code with a label at the begining of them so that in other words lets say when the game was saved you were in the forest. So when you load the game these text values would be stored into these variables Forest$ = "True"
Beach$ = "False" and then you could do condition checks.

If Forest = "True"
Go To Forest
else
Go to Beach

of course this is all just in psuedo code, and there would be many more flags that would have to be loaded but would this concept work?
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 3rd Jun 2005 11:00
LordDario,

Yes, the method will work. However, why would you need different sections of code for the forrest and the beach? Are the physics different in each of the areas, or whatever else can possibly change? I don't have a clue as to how your game is set up.

To add, if you simply save the location of the player, his coordinates, then you can use these coordinates when loaded to check to see what bounds the player is within. This is the alternate to saving an extra string of code.


+NanoBrain+
LordDario
22
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 3rd Jun 2005 12:43
well the reason coordinates wouldnt really work for me is because i have no world really set up. In other words i dont have a 2d or 3d matrix. The game im creating is actually a text based game with different areas you can go to depending on what text you type in. If i had an actual world set up i see what you are saying i could just send him to the saved coordinates, but thats not the case.
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 3rd Jun 2005 14:28 Edited at: 3rd Jun 2005 18:50
LordDario,

Escuse me for my overriding, but below is code which is a very, very efficient and editable way to create text adventures. I worked on this most of the night tonight, and figured it was good show I would introduce it to you.

The first code snippet is the 'engine' of the game. The second is a 'formatted' text file, which includes grid data. Let me explain. Essentially, a text adventure can be laid out into an imaginable grid. This grid is the basis of the way I have written this program.

Save the code snippets into the same folder, saving the second snippet as txtadventure.txt. Study the program, which is heavily commented for your convienience. Also, within it, notice the variable named grid. This is the variable you should save into a file when the user wishes to save his current game location. The program, at its top, can be slightly changed to include code to load its value, plus values of what the character has gained throughout his journey.

Let me explain the format of the .txt file, starting from line 1 to line 9.

1.) Grid number - the program will compare this to the grid number needing to be found. Once found, the group of lines underneath it, all the way to the next grid number, will be extracted for use as the current grid data

2.) The next four lines is the text that will be displayed on the screen for that current grid. The program is setup to print as many lines of text as needed for that grid. Feel free to add more lines to this point in the text file

3.) The next four lines are the values that are filled into the direction array, referencing, in order to, north, south, east and then west. A 1 stands for 'enabled', a 0 for 'disabled', and allows the player to only travel in specific directions for that grid. In the program, if an array slot is enabled, and its corresponding arrow key is pressed(up arrow for north, down arrow for south, etc), then the grid will be changed, if so be the direction is enabled.

Program:


Text file:save as txtadventure.txt:


The program is simply a game engine for this type of game. Therefore, all you have to do to make a new game or new grid, is add to or edit the .txt file. Enjoy!


+NanoBrain+

Login to post a reply

Server time is: 2025-05-23 02:01:28
Your offset time is: 2025-05-23 02:01:28