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.

Code Snippets / Game Saving & Loading & Pause Code

Author
Message
nukesoft games
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location:
Posted: 6th Aug 2004 22:37
I please need a game saving and loading code so when you save it, you come back to it when you load it pressing L, so, I've got a menu saying New game = N, Load game = L, Quit = Esc, Save = S, and PLEASE I need to know how to do that.

I'll make you all a deal, the first one to POST back, get's a play test of my upcoming game Death Bay!

Ali - Nukesoft

Why do I need a signature? :/
Kohaku
20
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 6th Aug 2004 23:00
I'm first to post back, yay, I get a play test!

Shame your question is in the wrong forum though dude.
You only post the code snippets to give out here, try the newcomers forum.

This is where it gets locked...

Infra-Dark
Bring the 20 liners back!
#coding, like coding, but with a #
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 7th Aug 2004 02:29
Yes, and NukeSoft is a frequent offender at posting in the wrong forum. I think he's been told about 5 or 6 times now about only posting in the CORRECT forum.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
nukesoft games
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location:
Posted: 7th Aug 2004 20:19
Be quiet Mogie bear or whatever your name is

people make mistakes,

well, what forum shall i post it in?

Aura you DON'T get the play test, it was a fault, according to philip the bear.

Try next time! Aura in the forum phillip or whatever he says

Why do I need a signature? :/
The dude guy
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: In the streets of sasatuin
Posted: 7th Aug 2004 23:39
I got this from another thread but here it is! This is for Darkbasic 1 not Pro.

First
First you need to have a variable that holds the number of objects. You can use this for example:
a=0
obj=0
do
a=a+1
if object exist(a)=1 then obj=obj+1
if object exist(a)=0 then goto know
loop
know:
rem Know the variable obj holds the number of objects

Saving
Now you know how many objects there are, you can save all the coordinates of the objects. Use this for example:
if file exist("1.obj") then delete file("1.obj")
open file to write("1,obj",1)
for a=1 to obj
write string 1,str$(object position x(a))
write string 1,str$(object position y(a))
write string 1,str$(object position z(a))
next a

Loading
Now, everything is saved, you can load it and create the objects again. Use this:
open file to read("1,obj",1)
for a=1 to obj
read string 1,x$
read string 1,y$
read string 1,z$
make object box a,1,1,1
position object a,val(x$),val(y$),val(z$)
next a

Finally
This are only the basics, if you want to do it right, write to the first line the number of objects. You can also write the color and angles and size. You can save whatever you like. But remember, always write the data in the same order as you read it. I hope this is usefull for you.

Andrew Tamalunas
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 8th Aug 2004 07:56
very easy to make a pouse code..
just make a new do/loop
do
if yourkey()=1
goto _pouse
endif
loop
_pouse:
do

loop

()() O===={}::::::::
(--) "BORING!!"
0 0 dont know what to do now!
future boy
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: In a virus
Posted: 10th Aug 2004 19:40
Yo! This is Justin, ali's friend, I own southern future games and it is a division of nukesoft and he got me to say thanks to both GogetaX and the dude guy for the game saving a pausing code, you are the best! he says, and he offers you both SOON the play test, he wants to or might do sell it!

He got me to say this because he is on vacation in spain and he wishes you the very best in programming! And so do I!

Justin and Ali.

(NOTE: GOGETAX, YOU SPELT PAUSE WRONG! OH WELL!)

Excuse me, but I do believe that sucks a**!

www.freewebs.com/southernfuturegames
future boy
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: In a virus
Posted: 10th Aug 2004 19:41
Note again: That's helped me for my fps shooter as well!

Karl's Vendetta

THANKS!

Excuse me, but I do believe that sucks a**!

www.freewebs.com/southernfuturegames
Kohaku
20
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 11th Aug 2004 07:41
... Thats not fair...

Infra-Dark
Bring the 20 liners back!
#coding, like coding, but with a #
Retro Addict
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location: Georgia, USA
Posted: 12th Aug 2004 02:54
This might be too late, but here's a simple pause routine that I think Jessticular showed in the forums before....This code came straight out of my current game and works very well.

If inkey$() = "p"
While inkey$() = "p" :EndWhile
While inkey$() <> "p" :EndWhile
While inkey$() = "p" :EndWhile
EndIf

PC Specs: AMD 1800+ 512M DDR, Radeon 128meg DDR - DB v1.13

To DB or not to DB............duh DB!
The dude guy
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: In the streets of sasatuin
Posted: 12th Aug 2004 10:24
Here's another one for DBC even though it's too late.

rem save function
if savegame()=1
open to write 1,"savegame.dat"
for t=1 to 1
write string 1,object position x()
next t
for t=2 to 2
write string 1,object position y()
next t
for t=3 to 3
write string 1,object position z()
next t
for t=4 to 4
rem what ever your game stats are
next t
endif

Andrew Tamalunas
The dude guy
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: In the streets of sasatuin
Posted: 12th Aug 2004 10:26
Here's one for Darkbasic Pro.

rem Example of player info needed to save & load game:

type Player
Level as string
Score as string
object1 as string
life as string
orbs as string
endtype
dim Gamer as Player

rem data below are handled during the game....


rem Create the string that contains the player stats
player$=player.level+","+player.score+","+player.object1+","+player.life+","+player.orbs+","

rem open the file & writes the string
open to write 1,"Player.sav"player.level="01"
player.score="250"
Player.object1="Bottle"
player.life="99"
player.orbs="4"

write string 1,Player$

rem The saving is complete at this point.
rem to read datas:

open to read 1,"Player.sav"
read string 1,Player$

dim Stats$(5)
Field=0
for a=1 to len(player$)
if mid$(player$,a)="," then stat$(Field)=Extract$:extract$="":inc field,1:goto passing
extract$=extract$+mid$(player$,a)
passing:
next a

player.level=stat$(0)
player.score=stat$(1)
Player.object1=stat$(2)
player.life=stat$(3)
player.orbs=stat$(4)

rem here we go...

Andrew Tamalunas
The dude guy
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: In the streets of sasatuin
Posted: 21st Aug 2004 07:05
Is the game almost done yet?
(Just an escuse so the tread doesn't get locked)

Andrew Tamalunas
The dude guy
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: In the streets of sasatuin
Posted: 5th Sep 2004 06:40
DON'T DIE!

Andrew Tamalunas

Login to post a reply

Server time is: 2024-11-23 20:08:51
Your offset time is: 2024-11-23 20:08:51