473,395 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Save Game

134 100+
I am trying to make a little Text-Based RPG (in the Win95 window and everything like that)
and it is oobviosly in C++.
Is there a way i could save progress in the game (such as record and load data like goldleft, questcomplete)

thanks
May 5 '07 #1
3 2475
Savage
1,764 Expert 1GB
I am trying to make a little Text-Based RPG (in the Win95 window and everything like that)
and it is oobviosly in C++.
Is there a way i could save progress in the game (such as record and load data like goldleft, questcomplete)

thanks
Yes.Use files
For e.g:

Now if I assume that experiance gold an all those staffs are variables in ur programm u could print that in file whne user decides to save:

quest1 start;
quest1 finished;

<Do u wanna save the current progress(Y\N)>

<Y>

quest1 start;
quest1 finished,saved,gold=,experiance=...

And then when loading search the line that contains saved and read it in.
Later use a tokenizer to pull out values

Savage
May 5 '07 #2
lumpybanana247
134 100+
Yes.Use files
For e.g:

Now if I assume that experiance gold an all those staffs are variables in ur programm u could print that in file whne user decides to save:

quest1 start;
quest1 finished;

<Do u wanna save the current progress(Y\N)>

<Y>

quest1 start;
quest1 finished,saved,gold=,experiance=...

And then when loading search the line that contains saved and read it in.
Later use a tokenizer to pull out values

Savage

experiece and gold are like
Expand|Select|Wrap|Line Numbers
  1. int experieice;
  2. in gold;
  3.  
then quest 1 finished is like
Expand|Select|Wrap|Line Numbers
  1. bool quest1finished=true;
  2.  
so is it the same thing?
how do i search the line when i load?
whats a tokeniazer?

thanks
May 5 '07 #3
Savage
1,764 Expert 1GB
experiece and gold are like
Expand|Select|Wrap|Line Numbers
  1. int experieice;
  2. in gold;
  3.  
then quest 1 finished is like
Expand|Select|Wrap|Line Numbers
  1. bool quest1finished=true;
  2.  
so is it the same thing?
how do i search the line when i load?
whats a tokeniazer?

thanks
U will need to output first all of that data into a file.For the load take this example:

quest1:start,
quest1:finshed,
quest2:start,
quest2:finished.saved,gold=,exp=,

Now onto how to load a file:

As u can see every line has it's format:

quest<quest no.>operator ':' <quest status> operator '.' or operator ','

Now to the tokenizer.Tokenizer searchs the string for the first ocurance of symbols setted as it's parametar and returns a pointer to the first character in given string adn writes '\0' character just after the token.After first call it has for parametar, instead of line,a NULL pointer.For example:

In c/c++ tokenizer is strtok();

So if have string like:

quest1:finished.saved,gold=<value>,exp=<value>

The string should become:

quest1
finished
saved
gold
<value>
exp
<value>


For reference on using strtok() check this out.

Savage
May 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

40
by: Mark G. Meyers | last post by:
http://www.savetheinternet.com There is more info and A PETITION at moveon... Easy to sign and give your two cents (and to your own reps in the process)....
1
by: fowle040 | last post by:
I underlined and bold print my files. I need to know how to make this code into a working game. The object of the game is to have two players 1- belle and 2-beast. I want them to lose and gain...
1
tpgames
by: tpgames | last post by:
I don't understand how to write a JavaScript to save the users progress in a game, so they can go back to the game at a later time. There is two games that really need this functionality, a php...
6
by: lumpybanana247 | last post by:
im making a text-based rpg in c++. is there a way i can make it so you can save your game and pick up where you left off?
3
by: I Hate My Computer | last post by:
Hi, I was wanting to make a game with the ability to save the level and the score. I would also like it to be able to load that saved game. Lastly I would like it to be able to save a high score...
1
by: Rhm3769 | last post by:
new to this, been looking around and haven't found anything for it yet.... I'm trying to write a script to help out tournament organizers for this online Risk site.... what I'm trying to do is...
4
by: powerovergames | last post by:
I wrote a simple gambling game using java, and I wish to let the user to save their record(i.e # of rounds played, points gained per round) so after quitting they game, they could keep on playing...
5
by: pankajs | last post by:
Hello frnds! I hve written a game in java & it is completed except saving & loading, ca anybody tell me how can i save a game status in a file ?????
1
by: Pankhuri | last post by:
Hello I am making a game in python, using PyGTK and not glade or PyGame. I wanted to know how can i save a currently opened game and also open an already saved game. Thank you for the help.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.