saving

BlitzPlus Forums/BlitzPlus Programming/saving

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How would i make it where this code saves and load each type, so you can save, move them all, load, and they return to all of there own postions where they were saved?

If you even understood that, the code is below. It only makes one dot return to its original position, instead of all of them. Sorry its not formatted correctly. I dont know how to make the code have its own spiffy little box. thnx.








Type p
Field x,y
End Type

p.p = New p

p\x= 100
p\y = 200



p.p = New p

p\x= 170
p\y = 249


p.p = New p

p\x= 500
p\y = 100




Graphics 800,600



While Not KeyHit(1)
Cls



For p.p = Each p



;loads the dots position
If KeyHit(2)
; Open a file to write to
fileout = WriteFile("mydata.dat")

; Write the information to the file
WriteInt( fileout, p\x)
WriteInt( fileout, p\y )


; Close the file
CloseFile( fileout )
EndIf





;loads the dots position
If KeyHit(3)
; Open a file to write to
filein = ReadFile("mydata.dat")

; Write the information to the file
p\x=ReadInt( filein )
p\y=ReadInt( filein )


; Close the file
CloseFile( filein )
EndIf





;draws the dot
Oval p\x,p\y,10,10


;moves each dot around
If KeyDown(200)
p\y=p\y-2
EndIf

If KeyDown(208)
p\y=p\y+2
EndIf

If KeyDown(203)
p\x=p\x-2
EndIf

If KeyDown(205)
p\x=p\x+2
EndIf



Next

Flip
Wend