AppTitle "My little box"Graphics3D 800,600,32,2SetBuffer BackBuffer()Global message$ = "move the boxes... '[' and ']' to change box"Type test Field x Field y Field z Field name$ Field shapeEnd TypeFor count = 1 To 4 n.test = New test nx = Rand(10) ny = Rand(10) nz = Rand(10)+10 name$ = Chr(Rand(26)+65) +Chr(Rand(26)+65) +Chr(Rand(26)+65) nshape = CreateCube() EntityColor nshape, count*50, 0,0Nextcamera=CreateCamera()light=CreateLight()RotateEntity light,0,0,90Global reload.testGlobal control.test = Last testmaxshape = controlshapecontrol.test = First testminshape = controlshapeRepeatIf KeyDown(200)=True Then controly = controly + 1If KeyDown(203)=True Then controlx = controlx - 1If KeyDown(205)=True Then controlx = controlx + 1If KeyDown(208)=True Then controly = controly - 1If (KeyHit(26)=True And controlshape <> minshape) Then control = Before controlIf (KeyHit(27)=True And controlshape <> maxshape) Then control = After controlFor update.test = Each test PositionEntity updateshape, updatex, updatey, updatezNextIf KeyHit(64) Then saveIf KeyHit(65) Then load UpdateWorld RenderWorld Text 20, 20, message$Flip Until KeyHit(1)End ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Function save()fileout = WriteFile("Shay1.SM")For n.test = Each test Print Str$(n) WriteString (fileout, Str$(n)); WriteFloat (fileout,cube); WriteFloat (fileout,EntityX); WriteFloat (fileout,EntityY); WriteFloat (fileout,EntityZ)NextCloseFile( fileout ) Cls message$ = "game data written to file..."FlushKeys End Function;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Function load()ClsFor destroy.test = Each test FreeEntity destroyshape Delete destroyNextfilein = ReadFile("Shay1.SM") While Not Eof(filein) Read1$ = ReadString$( filein ) ;Read1$ = ReadFloat( filein ) If Read1$<>"" Then reload.test = RestoreTestInfo(Read1$) EndIfWend DebugLog "finished with loaded file"FlushKeyscontrol = First testEnd Function ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Function RestoreTestInfo.test( SavedString$ ) message$ = "Read from file --> " + SavedString$ + " ... " DebugLog message$ ; typical type looks like ... [-3,-4,14,"LQT",18898368] SavedString$ = Mid$( SavedString$, 2, Len(SavedString$)-2) ; remove end square brackets firstcomma = Instr(SavedString$, ",") xvalue% = Left$(SavedString$, firstcomma-1) ; convert first value (up to comma) to an int SavedString$ = Mid$( SavedString$, firstcomma+1, Len(SavedString$)-firstcomma+1) ; eat up to 1st comma firstcomma = Instr(SavedString$, ",") yvalue% = Left$(SavedString$, firstcomma-1) ; convert up to new first comma to another int SavedString$ = Mid$( SavedString$, firstcomma+1, Len(SavedString$)-firstcomma+1) ; eat up to new 1st comma firstcomma = Instr(SavedString$, ",") zvalue% = Left$(SavedString$, firstcomma-1) ; convert up to new first comma to another int SavedString$ = Mid$( SavedString$, firstcomma+1, Len(SavedString$)-firstcomma+1) ; eat up to new 1st comma ThirdString$ = Mid$( SavedString$, 2, Len(SavedString$)) ; remove first quote from string firstcomma = Instr(SavedString$, ",") ThirdString$ = Mid$(SavedString$, 2, firstcomma-3) message$ = message$ + "x: " + xvalue + " y: " + yvalue + " z: " + zvalue + " name: " + ThirdString$ DebugLog message$ reloaded.test = New test ; make a new type reloadedx = xvalue% ; and assign the reloadedy = yvalue% ; reloaded values reloadedz = zvalue% reloadedame$ = ThirdString$ ; to the fields reloadedshape = CreateCube() Return (reloaded) End Function;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++