From what I understand you just want to somehow save the state of the game, and when the game starts again, start off from the same position in the game?
The simplest and easiest method for that is to create two routines for loading and saving your game.
The main concern in a game is saving all the data in your variables and arrays. Let's assume you have a player and an enemy with the following data:
PlayerPosX# as float
PlayerPosY# as float
PlayerPosZ# as float
PlayerName$ as string
EnemyPosX# as float
EnemyPosY# as float
EnemyPosZ# as float
EnemyName$ as string
You'll have to save all of that data to a file. This can be done like this:
rem delete existing save file
if file exist( "save.dat" ) then delete file "save.dat"
rem save all data to file
open to write 1, "save.dat"
write float 1, PlayerPosX#
write float 1, PlayerPosY#
write float 1, PlayerPosZ#
write string 1, PlayerName$
write float 1, EnemyPosX#
write float 1, EnemyPosY#
write float 1, EnemyPosZ#
write string 1, EnemyName$
close file 1
You should save your game just before you end your program.
Loading your game again requires you to read all of that data back into the game, which you should do right when you start your program. The code for that is very similar:
rem check if save file exists
if file exist( "save.dat" )
rem load all data from file
open to read 1, "save.dat"
read float 1, PlayerPosX#
read float 1, PlayerPosY#
read float 1, PlayerPosZ#
read string 1, PlayerName$
read float 1, EnemyPosX#
read float 1, EnemyPosY#
read float 1, EnemyPosZ#
read string 1, EnemyName$
close file 1
endif
This is just a very simple example, you'll have to adapt it to fit your own needs.
TheComet
Private CARROT() As Char = {"^"c}
- The codebase