|
Post by Azan on Jul 29, 2005 15:01:50 GMT -5
I was bored so I made this, should help people learn how to save files, maybe ill write a tutorial when we get our new site up :) Graphics 800,600 SetBuffer BackBuffer()
Global input3$ ;holds the info in a global
Type box Field x,y End Type
Print "Do you want To (L)oad a game Or start a (N)ew one?" ;simple stuff that gets the file names in variables input1$=Input$("-->>") If input1$="L" Or input1$="l" Then Print "Whats the name of the file you want to load?" input2$=Input$("-->>") load(input2$) EndIf If input1$="N" Or input1$="n" Then Print "What do you want to name your file?" input3$=Input$("-->>") EndIf
While Not KeyHit(1) Flip Cls If MouseDown(1) Then createbox() EndIf updatebox() If KeyHit(57) Then ;if the spacebar is clicked then save save() EndIf Text 50,50,"click the mouse to create boxes, hit space to save" Wend End
Function createbox() ;create a new box at the mouse coordinates b.box = New box b\x=MouseX() b\y=MouseY() End Function
Function updatebox() ;draw our boxes For b.box=Each box Rect b\x,b\y,15,15 Next End Function
Function save() file=WriteFile(input3$+".txt") For b.box=Each box WriteLine(file,b\x) ;for all boxes write their coordinates WriteLine(file,b\y) Next End Function Function load(inp$) file=OpenFile(inp$+".txt") While Not Eof(file) ;go through the entire file b.box=New box b\x=ReadLine(file) ;read the lines and assign it to type info b\y=ReadLine(file) Wend End Function
|
|
|
Post by Azan on Aug 6, 2005 13:34:18 GMT -5
Graphics 800,600 SetBuffer BackBuffer()
Global input3$ ;holds the info in a global
Type box     Field x,y End Type
Print "Do you want To (L)oad a game Or start a (N)ew one?" ;simple stuff that gets the file names in variables input1$=Input$("-->>") If input1$="L" Or input1$="l" Then     Print "Whats the name of the file you want to load?"     input2$=Input$("-->>")     load(input2$) EndIf If input1$="N" Or input1$="n" Then     Print "What do you want to name your file?"     input3$=Input$("-->>") EndIf
While Not KeyHit(1)     Flip     Cls     If MouseDown(1) Then         createbox()     EndIf     updatebox()     If KeyHit(57) Then ;if the spacebar is clicked then save         save()     EndIf     Text 50,50,"click the mouse to create boxes, hit space to save" Wend End
Function createbox() ;create a new box at the mouse coordinates     b.box = New box     b\x=MouseX()     b\y=MouseY() End Function
Function updatebox() ;draw our boxes     For b.box=Each box     Rect b\x,b\y,15,15     Next End Function
Function save()     file=WriteFile(input3$+".txt")     For b.box=Each box         WriteLine(file,b\x) ;for all boxes write their coordinates         WriteLine(file,b\y)     Next End Function      Function load(inp$)     file=OpenFile(inp$+".txt")     While Not Eof(file) ;go through the entire file         b.box=New box         b\x=ReadLine(file) ;read the lines and assign it to type info         b\y=ReadLine(file)     Wend End Function      |
|
|