Page 1 of 2

Two Questions, Can you help me?

PostPosted: Sat Jun 02, 2007 10:13 pm
by Rux
Can anybody answer these questions for my next game?

1.How do you save a game :?: (I know how to save a score, but not a game)
2.How do you make a typing box :?:
PLEASE HELP! :o :o :o :o :o :o :o :o :o :o :o

PostPosted: Sat Jun 02, 2007 10:45 pm
by d-soldier
Saving a game is very complex stuff... you basically have to setup save a gang-load of variables, and then when resuming use the loadvar thing. You would have to set up a varibale to not only record the status of all the ingame variables, but also the player's location, ammo, etc... perhaps Sparky, Gogo, or Fuzzy would be able to help with this... And be sure when posting on the forum to make your post's title have something to do with the subject of the post, not "Help me" or "couple questions".

PostPosted: Sat Jun 02, 2007 11:47 pm
by Game A Gogo
ah, saving game is pretty easy!
I shall make a demo?

PostPosted: Sun Jun 03, 2007 1:36 am
by Rux
Ok, what about a typing box or type field? :?: ?

PostPosted: Sun Jun 03, 2007 1:43 am
by Jay S.
To create a type box, first of all, create a simple text actor. Then, once you are finished choosing your font and other, notice on the lower left corner of the window there is a "Text Input" button. If you set this to yes, then the user can type their own text in this area. :) (If you click the "Config" button beside this, you can change other attributes, such as the border color, etc.)

I haven't used this feature much, but by what I know, it appears to me that how much text you enter in for the text actor determines how large the type box is...

PostPosted: Sun Jun 03, 2007 1:53 am
by Rux
Cool, thanks! :D

PostPosted: Sun Jun 03, 2007 3:10 am
by Rux
Game A Gogo wrote:ah, saving game is pretty easy!
I shall make a demo?


Please post a link or post the demo in this topic. :wink:

PostPosted: Sun Jun 03, 2007 5:56 am
by Sgt. Sparky
Rux wrote:
Game A Gogo wrote:ah, saving game is pretty easy!
I shall make a demo?


Please post a link or post the demo in this topic. :wink:

I made a file saving of multiple Actors Positions,
simple just use on the create actor event of the view after you have your variables,
Code: Select all
FILE*file;
file = fopen("Game", "r+b");
fread(&variable1, sizeof(variable1), 1, file);
fread(&variable2, sizeof(variable2), 1, file);
//ect.
fclose(file);
so and so Actor.x = variable_whatever; //ect.

and for the draw Actor event of your Player,
Code: Select all
FILE*file;
so and so variable_whatever = Actor.x; //ect.
file = fopen("Game", "w+b");
fwrite(&variable1, sizeof(variable1), 1, file);
fwrite(&variable2, sizeof(variable2), 1, file);
//ect.
fclose(file);

:D
(Here is a Link to a File Saving Demo I made: http://game-editor.com/forum/tp-3450-Fi ... ions-.html )

PostPosted: Sun Jun 03, 2007 9:43 pm
by Rux
Please edit your post and remove all useless scripting.
Still use var #s (Variable1). The so and so (ect...) is confusing :?

PostPosted: Sun Jun 03, 2007 11:22 pm
by Game A Gogo
I just remembered that I made something about it, go on the demo forum and go to Gui, it has game saving in it.

PostPosted: Sun Jun 03, 2007 11:34 pm
by Kodo
It'll be easier if you only allow the player to save between levels or at checkpoints where there is less to worry about. You could create a save game in this manner by just saving a few common grouped variables like the ones listed below with saveVars(“filename”, “group”)

current_level
player_score
player_health
lives_remaining

When you create the variables you want to save you can put them in a Save Group, this group will be what the saveVars/loadVars functions load and save. If you need to you can edit variables to place them in a save group after they have been created.

When the player chooses to reload their saved game you load the data again using loadVars(“filename”, “group”) , look at the level and place the character and/or view in the correct position, set all the other saved variables and off you go!

Taking this approach you really don’t need to worry about where all the monsters were, which pickups the player has already cleared from a level, were there bullets flying about the place? which frames of animation were all the sprites on? what damage had been done to the environment and on and on etc etc. It's much simpler.

If you are worrying about keeping track of remapped controls, music/fx volumes and other optional stuff I prefer to keep those saved in a separate player profile group that I can load and save in the front end menus and also load when starting up the game separately from the save game info.

PostPosted: Mon Jun 04, 2007 4:14 pm
by Sgt. Sparky
Kodo wrote:It'll be easier if you only allow the player to save between levels or at checkpoints where there is less to worry about. You could create a save game in this manner by just saving a few common grouped variables like the ones listed below with saveVars(“filename”, “group”)

current_level
player_score
player_health
lives_remaining

When you create the variables you want to save you can put them in a Save Group, this group will be what the saveVars/loadVars functions load and save. If you need to you can edit variables to place them in a save group after they have been created.

When the player chooses to reload their saved game you load the data again using loadVars(“filename”, “group”) , look at the level and place the character and/or view in the correct position, set all the other saved variables and off you go!

Taking this approach you really don’t need to worry about where all the monsters were, which pickups the player has already cleared from a level, were there bullets flying about the place? which frames of animation were all the sprites on? what damage had been done to the environment and on and on etc etc. It's much simpler.

If you are worrying about keeping track of remapped controls, music/fx volumes and other optional stuff I prefer to keep those saved in a separate player profile group that I can load and save in the front end menus and also load when starting up the game separately from the save game info.

But But....
Thats to easy! :cry:

(I made a different kind of File saving(file making Demo I made)

PostPosted: Mon Jun 04, 2007 7:19 pm
by Kodo
Sgt. Sparky wrote:But But....
Thats to easy! :cry:
lol

What I suggested is just the one way of doing it and it happens to suit my needs most the time; your way is perfectly ok and depending on what you need for your game may be preferred :) It's really good that people present different ways of doing things on these forums and share ideas; it shows the flexibility of GE as well broadening peoples understanding of what's possible!

+ 1 point for Sparky (again!)

PostPosted: Mon Jun 04, 2007 9:34 pm
by Sgt. Sparky
1 + Point For you! :D

PostPosted: Sat Jun 23, 2007 10:35 pm
by Rux
I finally get Sgt.Sparky's script!
The first part ended up like this,
( view,create actor, script editor
Code: Select all
FILE*file;
file = fopen("Game", "r+b");
fread(&PlayB_Var, sizeof(PlayB_Var), 1, file);
fread(&Menu_var, sizeof(Menu_var), 1, file);
fread(&QuitB_Var, sizeof(QuitB_Var), 1, file);
fread(&Register_Var, sizeof(Register_Var), 1, file);
fread(&Seirial_Var, sizeof(Seirial_Var), 1, file);
fread(&Sessions_Var, sizeof(Sessions_Var), 1, file);
fread(&registerthegame_Var, sizeof(registerthegame_Var), 1, file);
fread(&sep_Var, sizeof(sep_Var), 1, file);
fread(&session_Var, sizeof(session_Var), 1, file);
fclose(file);
PlayB.x = PlayB_Var;
Menu.x = Menu_var;
QuitB.x = QuitB_Var;
Register.x = Register_Var;
registerthegame.x = registerthegame_Var;
Seirial.x = Seirial_Var;
sep.x = sep_Var;
session.x = session_Var;
Sessions.x = Sessions_Var;
) :shock: :shock: :shock: