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.

Newcomers DBPro Corner / How do you make a save/load for your games?

Author
Message
Young_Noob
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 16th Dec 2002 02:21
How do you make a save and load program to put in my game?
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 16th Dec 2002 04:14
You need to write your needed information into an array and save that array in a file. Then, load the file, which contains the arrays, and pop them in your program Im not the best with arrays, but I pretty sure this is how to do it

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 16th Dec 2002 04:15
PS- It helps telling what kind of game your making. Like if your making an RPG you would have to save the object position, gold, money, expierience and oh so much more

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
Young_Noob
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 16th Dec 2002 23:47
i am trying to make an rpg, but because i am a newb i am finding it extremely hard to get my models, i've been trying to make them, but i can't do it, i am not good enough artsist to shape and it is hard to animate them. But yeah, i am making an rpg. If it is possible, can you please maybe make me a small .dba file explaining how i would do this so i could save it in my tutorials folder to study later?

Thanks for your help!

Young_Noob
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 16th Dec 2002 23:48
By "do this" in my last post i mean make a save/load file please!

I would be very grateful!

Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 17th Dec 2002 00:15
Why are you trying to make an rpg. Rpg is the thing all Noobs try first and they are the most difficult and tedious type. If you are a noob (i am a semi-noob) then i suggest that you create some variety of arcade game

If you forget one little thing i shall have you shaved sterilised and destroyed: Jeffrey Goines
hexGEAR
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 17th Dec 2002 00:28
hmm, well, when i started off my mind flew stright into making an rpg, however, i did make some sub-games like flight sims, shoot-em-ups, etc to develope my abilities to the point, if your confident you can start and finnish your game then go for it!

as for saving, rpggamer is correct, simply note what you want to be saved such as gold, world position coordinates, etc and make any old file say save_game1.dat and store your data in there, when you need them, load them again and assign your variables to the loaded data.

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
ChronicFear
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 17th Dec 2002 06:43
Can someone plz explain how I would go about saving a matrix? Im trying to make a multi level, mid futer shoot em up, online game, which, i am a n00b, but, im going to hone my skils by adding onto it, until its done

Your suffering cause of me its divine
-Korn-
Bulleyes
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 17th Dec 2002 07:16
But sounds a little bit ignorant... but what is NOOB, SEMI-OOB and OOB?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
ironhoof
21
Years of Service
User Offline
Joined: 3rd Sep 2002
Location:
Posted: 17th Dec 2002 09:50
Correction an RPG ENGINE is the hardest thing to make ^_^
I can spitout complete RPG's all year long infact I have.

-----\
There was a man on the stairs that wasn't there.
He wasn't there agian today I think he's from the CIA.
Tywald
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sweden
Posted: 17th Dec 2002 10:56
It´s quite easy to save information into a file and load it back later, here´s an example.

I have 6 variables that contains the player´s X Position, Y Position, Z Position, character name, current hitpoints and experience.

Player_X#
Player_Y#
Player_Z#
Name$
Hit_Points
Exp

Now, let´s save this information into a file called "Savegame.sav"

Delete the old Savegame.sav if it already exists one.
IF FILE EXISTS("Savegame.sav") = 1 THEN DELETE FILE "Savegame.sav"
Create a new Savegame.sav
OPEN TO WRITE 1,"Savegame.sav"
WRITE FLOAT 1,Player_X#
WRITE FLOAT 1,Player_Y#
WRITE FLOAT 1,Player_Z#
WRITE STRING 1,Name$
WRITE LONG 1,Hit_Points
WRITE LONG 1,Exp
CLOSE FILE 1

And if i want to restore it:

First, check if to file exits.
IF FILE EXISTS("Savegame.sav") = 1
OPEN TO READ 1,"Savegame.sav"
READ FLOAT 1,Player_X#
READ FLOAT 1,Player_Y#
READ FLOAT 1,Player_Z#
READ STRING 1,Name$
READ LONG 1,Hit_Points
READ LONG 1,Exp
CLOSE FILE 1
ELSE
PRINT "Error, the file savegame.sav could not be found!"
ENDIF

Now, when the game menu appears the player can choose to start a new game or load a game.

Game_Menu:
PRINT "(N)ew game"
PRINT "(L)oad game"
INPUT "Make your choice: "; choice$
IF choice$ = "n" THEN GOTO New_Game
IF choice$ = "l" THEN GOTO Load_Game
`If the choice is neither n or l then end the game.
END

`When the player chooses to start a new game then use the default settings for the name and the other stuff.
New_Game:
Player_X# = 1.0
Player_Y# = 1.0
Player_Z# = 1.0
Name$ = "Default"
Hit_Points = 100
Exp = 0
`After that go to the main loop for the game.
GOTO Game

`As the New_Game gives the variables the default settings the Load_Game loads the
`information from a file and gives the variables that information.

Load_Game
`**** Put the load file code that i wrote in the beginning here ****
GOTO Game

Now, i have a main game loop and to save the current status
i press a key.

Game:
DO
`blaha blaha player control and other stuff.

IF INKEY$() = "s" THEN GOSUB Save_Game:
SYNC
LOOP

Save_Game:
`***** Put the save file code i wrote in the beginning here *****
RETURN

Now everytime i press "S" on the keyboard then call the Save_Game subroutine to save the current player information into a file.

Hopefully this help will give you a fair idea on how to load and save the player information into a file and then restore it.

- Tywald

John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 17th Dec 2002 13:49
For the matrix, just make on in MatEDIT (www.matedit.com) it writes all the DB code for you, so you dont have to worry about it being random every time

RPGamer

Other than that- he just about hit the nail on the head with saving. Nice job!

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
ChronicFear
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 17th Dec 2002 16:43
You guys are freakin awesome, lol. Thanks for all the help on my side of things. But, what variables and arrays would I save for the matrix?

Your suffering cause of me its divine
-Korn-
Tywald
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sweden
Posted: 17th Dec 2002 17:06
ChronicFear:

I'll suggest that you use programs like MatEDIT to create matrices and load them into your game.
It´s easier and also faster than trying to figure out what Y coordinate that specific point in the matrix are and write code that saves the information and also write a code to restore the coordinates to a flat matrix.

- Tywald
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 17th Dec 2002 21:23
a simple height map can be used to create different levels from one matrix such as this DB Classic v1.13 code:


useage:
put a 50x50 grayscale .bmp file in the same folder as this code then run the code. When the code is executed enter the filename WITHOUT the suffix (enter 'level1' for 'level1.bmp' file!) then hit enter, this will generate the .dat file for that level which can be loading in your program again using this code:


easy! The grayscale levels in the .bmp file determine the terrain height. i.e. if this image is used you get a 3d maze terrain!

P.S. this code is very old so it may need a little tweaking, try it and find out i know that it acts a little strange in DBPro

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
Young_Noob
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 17th Dec 2002 21:48
Thanks for your help guys!

ChronicFear
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 17th Dec 2002 21:58
Yeah guys thanx. Especially you Kale, that program will be quite useful, but, I have a couple of questions. How will it be textured? Is there any way to load a hmp file into the game, if I have the heightmap already rendered and such?

Your suffering cause of me its divine
-Korn-
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 17th Dec 2002 23:55
Each matrix is made up of tiles and each of these can be textured individually using the 'set matrix tile' command or you can texture the whole matrix with a large texture to cover all tiles seemlessly like this:



which is nice for seemless terrain at the cost of texture quality as many graphics cards don't like textures 1024x1024+. I guess though you could divide the matrix up into quarters and modify this code to seemlessly texture it in 4 pieces.

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
ChronicFear
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 18th Dec 2002 00:45
Thanx again, I dont know which Im going to use. The Matedit thing generates tons of runtime errors, and, is not user friendly, and, that way take tons of time to prog. How would I load a terrain I made in Matedit to DBpro?

Your suffering cause of me its divine
-Korn-
Tywald
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sweden
Posted: 18th Dec 2002 10:22
ChronicFear:

Load up MatEDIT and create a new Matrix, give the project a name, create your matrix and when you´re done press B to build a *.mdf file and a *.bmp file.

Move those newly created files and the file "LoadMatrix.dba"(can be found in support\includes) to your project directory. Now open the file Dims.dba (support\dim block) and copy everything there.

Now, open your game and add these lines:

#INCLUDE "LoadMatrix.dba"

**** Put the lines of code that was in Dims.dba here ****

To load your matrix just add the line:

Succes=LoadMatrix("Matrixname",1)

A example:

I create a new matrix in MatEDIT and the project is called Level1, i create a matrix and hit b to save it.
Now in the directory "Level1" (under the directory Projects)i copy the files "Level1.mdf" and "_Level1.bmp" into my
game directory. I Also copy the LoadMatrix.dba file into my game directory.

After that i start to write my game code:

`************* Tywald´s Game.dba **************
#INCLUDE LoadMatrix.dba `<- IMPORTANT!

`---- I put every line that can be found in the dims.dba file here ----

Sync on
Sync rate 60
Succes=LoadMatrix("Level1",1)
DO
IF LEFTKEY() = 1 THEN TURN CAMERA LEFT 2.0
IF RIGHTKEY() = 1 THEN TURN CAMERA RIGHT 2.0
IF UPKEY() = 1 THEN PITCH CAMERA DOWN 2.0
IF DOWNKEY() = 1 THEN PITCH CAMERA UP 2.0
SYNC
LOOP

- Tywald
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 18th Dec 2002 13:22
I havent had any probs with MatEDIT Give it a couple tries. I only had trouble with the "Mountainrange" command. I easily overcame this by using the mouse tool to edit land.

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
ChronicFear
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 18th Dec 2002 19:29
Agh, Im running off of DarkBASIC pro's trial version, so, I dont have the Loadmap.dba file, can someone send it to me

Your suffering cause of me its divine
-Korn-

Login to post a reply

Server time is: 2024-04-12 22:55:53
Your offset time is: 2024-04-12 22:55:53