|
Post by Azan on May 29, 2005 19:14:53 GMT -5
Graphics 640,480 SetBuffer BackBuffer()
Type box Field x Field y End Type Global savefile = ReadFile("save.dat") If savefile <> 0 While Not Eof(savefile) b.box = New box b\x = ReadInt(savefile) b\y = ReadInt(savefile) Wend EndIf While Not KeyHit(1) Flip Cls Text 10,10,"Hit the space bar to save"
If MouseHit(1) b.box = New box b\x = MouseX() b\y = MouseY() EndIf
For b.box = Each box Color 0,0,255 Rect b\x,b\y,20,20,1 Next
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;SAVING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If KeyHit(57) Then WriteFile=WriteFile("save.dat") If WriteFile<> 0 For b.box=Each box WriteInt(WriteFile,b\x) WriteInt(WriteFile,b\y) Next CloseFile WriteFile Cls Text 0,20, "File saved. Any key to finish" Flip WaitKey() Else RuntimeError "Error with writefile" EndIf EndIf Wend
click the mouse to make a box then hit space to save it, next time you load the program all of the types info will be saved.
|
|
|
Post by Umbrafire on May 30, 2005 19:47:28 GMT -5
excellent program. later i'll try to understand it
|
|
|
Post by Azan on May 30, 2005 20:02:29 GMT -5
heres a little hint While Not Eof(savefile) b.box = New box b\x = ReadInt(savefile) b\y = ReadInt(savefile) Wend
this gets the newest line in the file
|
|
|
Post by Umbrafire on May 30, 2005 20:12:56 GMT -5
ohhh...i get it.... thanx...
|
|