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 Professional Discussion / Please help save and load games between State

Author
Message
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 4th Nov 2010 15:03
Please introduce code to save and load game between State !! T_T




...
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Nov 2010 16:06
I can point you in the right direction, but you'll have to code it yourself (unless of course someone out there is actually bored enough to code it for you).

What you have to do is save all of the variables you use in-game to a file, and the next time you load the game, load all of the variables from that file back into the game. So let's say you have variables a,b,c# and d$. To save them use:



And to load them back again:



TheComet

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 4th Nov 2010 22:47
If save at the end state ?

For example...
If save at the end state1 ,when load is the playing State 2.

**I've tried to do it. But it is wrong.

**Anyone help out to solve the code.

**I am not strong in English,sorry.



Pleas help, It was a graduation project !!!

...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Nov 2010 23:56 Edited at: 4th Nov 2010 23:58
Quote: "Pleas help, It was a graduation project !!!"

Not only are you not really trying to solve it yourself you're cheating on a graduation project? My willingness to help just evaporated... sorry.

You could at least put a little effort into getting it working...

Oh, alright I'll help.

[help]
Look into the read/write to file commands
[/help]

EDIT: Oh but I see you already found some help here: http://forum.thegamecreators.com/?m=forum_view&t=177437&b=1

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 08:19
This is a very short time.

I need guidance.

Will take a little time.



Pleas help, Thx.

...
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 09:19
Ok I'll try.

If there is a problem,I would take to code view.




...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 10:57
Have a go, if you get stuck post what you have here and I'll try to help without writing the code for you.

Sorry if I sound harsh but you really should be writing your own code if it's graduation work.

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 11:25
okay, After trying.

Write the following code.

Save the file sizes is small. right ?

When loaded, It does not load (Load Fail !!!).

Pleas help. T_T









...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 11:49 Edited at: 5th Nov 2010 11:51
I noticed a couple of things that might cause issues (your message will appear soon I got it by email):

1-I normally use "write string" just so I can see the results more obviously.

2-
Quote: "write float 1,object position x(charector) write float 1,object position y(charector) write float 1,object position z(charector) write float 1,object angle x(charector) write float 1,object angle y(charector) write float 1,object angle z(charector)"

You need to use colons if you are going to put commands on the same line... like this: "write float 1,object position x(charector): write float 1,object position y(charector)"

3-You are using a complete path in your loadgame code but a relative path in savegame, is the loadgame path correct?

4-You also use the check for whether the file exists twice...


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Nov 2010 14:16
What't this?

filename$= "C:\Program Files\dark\Projects\Mote4\save\SaveGame.dat"

shouldn't that be the following?

filename$="save\SaveGame.dat"

TheComet

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 14:17
Yeah,It works.

Thank you very much for the advice. Mr.baxslash


**My project will use the load game on the first page(main menu). It would be a problem ?,If there is a problem pleas help me.


** I'm not understand, My post is not show.



...
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 14:59
1)If save and exit the game
2)load the game to play in main menu, It error !!!




What's important to keep variables ?

Pleas help me.

...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 15:10
Post your current code I'll take another look...

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Nov 2010 15:25
Quote: "It error !!!"

You seriously want help from an 'error report' like that?
What error?

If you wrote the original code, then you should know exactly which variables are important to save and exactly which objects/sprites you need to save the settings of.

Then you save them.

When you load, you recreate all of the objects and sprites, applying settings from the saved data, and then restoring your variables.

After that, you should be pretty much ready to play again.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 15:33
Ian is right, you need to think "How can I get my game back to the exact place it is at right now?"

Also make absolutely sure you are reading them back in the same order you saved them...

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 15:39
ok, I will try.

If the problem is asking you.




...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 15:49
Quote: "If the problem is asking you."

I'm not sure I understand what you mean?

save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 5th Nov 2010 22:56
Now,loadgame while playing,I can do
I want loadgame after exit game.

What are the key variables that must be stored ? ,loadgame after exit game, Pleas help.


Quote: "If you wrote the original code, then you should know exactly which variables are important to save and exactly which objects/sprites you need to save the settings of.
"


I'm not understand, write sprite and object to save.



write long 1,....
write long 1,....

Pleas help me.

...
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Nov 2010 00:09
It's very simple.

When you load your game, you check to see if the sprite exists. If it doesn't, then you create it.

And you STILL haven't told anyone what the error is!

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 6th Nov 2010 06:47
Quote: "
It's very simple.

When you load your game, you check to see if the sprite exists. If it doesn't, then you create it.

And you STILL haven't told anyone what the error is!
"



I want to sample for ideas in making.



...
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 6th Nov 2010 06:56
I want to know, Can I save label ? , Then label will work ?

Ex.



If I could save by writing this.

write long 1,_setup

label will work ?

...
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 6th Nov 2010 09:07
You will have to save EVERY kind of data you want to remember and load in!

Arrays are a good way to do this

Here is an example of saving red boxes to a file then reading them in
the next time you run the program
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 6th Nov 2010 22:44
Thank you. Mr.BillR.


I'm not understand, Write sprite and object to save


I want loadgame after exit game.

I want sample for ideas in make.


Help me !!





...
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 6th Nov 2010 23:36
1) Save EVERYTHING you want to load later, variable values, arrays, etc.
2) Save everything as a string so you can debug your saved file easily
3) Organize your code so it's easy to keep track of loading and saving everything you need
4) In my example program I keep track and save the number of boxes created, as well as all the data for each box. Read through my program and study it until you understand saving EVERYTHING you want to load in later - this may take some time, but you will need to invest time in learning, don't be so impatient wanting a quick answer.
5) SHOW us your program so we can help. If you don't have a program to share, then you are not putting in enough effort and time to learn what you need to do.
save load game between state
15
Years of Service
User Offline
Joined: 4th Nov 2010
Location: Thailand
Posted: 7th Nov 2010 08:51
Thank you. Mr.BillR.

Ok I'll try.

...

Login to post a reply

Server time is: 2026-07-26 05:03:53
Your offset time is: 2026-07-26 05:03:53