-
Jan 6th, 2009, 01:12 PM
#1
Thread Starter
New Member
Load / Save Game Info
Im making a simple game but I have problem with getting a coda were i can save and load my information to a database or a file, i need to save several integer files and string files
Code:
Dim Level As Integer, XP As Integer,
dim PlName As String, Money As Integer, Mana As Integer, Life As Integer
This is what who needs to be saved, it will later on be a Online game how must the data be saved then?
-
Jan 11th, 2009, 11:07 PM
#2
New Member
Re: Load / Save Game Info
You could make it a .csv file, or wouldn't that work?
-
Jan 12th, 2009, 02:29 AM
#3
Thread Starter
New Member
Re: Load / Save Game Info
I really dont know :P Have no idea how a save function works... dont know any code to save anything almost :P If you do please share your knowledge
-
Jan 12th, 2009, 04:10 AM
#4
Hyperactive Member
Re: Load / Save Game Info
You can create a StreamWriter object, it's pretty simple:
http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx
-
Jan 17th, 2009, 03:02 PM
#5
Re: Load / Save Game Info
VB.NET: Use this.
Code Code:
Dim fs As New IO.FileStream("gamesave.bin",IO.FileMode.Write,IO.FileAccess.Read)
Dim wr As New IO.StreamWriter(fs)
wr.Write(level.toString & ",")
wr.Write(XP.toString & ",")
wr.Write(life.toString & ",")
wr.Write(mana.toString & ",")
wr.Write(money.toString & ",")
wr.Write(PLName)
wr.Close()
fs.Close()
VB6: Roughly this, but I don't use VB6.
Code Code:
Open "gamesave.bin" For Output As #File
Write #File, Str(level) & ","
'etc. for all of them.
Close #File
I'll write how to read the data and explain it later, I don't have much time
-
Jan 18th, 2009, 07:19 PM
#6
Re: Load / Save Game Info
Ok, so. You have the IO.FileStream and IO.StreamWriter/Reader objects, explore their constructors and you should get a pretty good idea on how to initialize those objects. You should then explore the StreamWriter/Reader's methods. Just remember: once you're done with the objects, run their Close() methods, not dispose. You must run Close() for all of the file-related objects (unless they don't have a Close() method). If you don't, you could have some funny errors.
-
Jan 19th, 2009, 11:07 PM
#7
Re: Load / Save Game Info
Perhaps writing a game is beyond your grasp at the moment.
I do not mean to offend, however if you are having troubles reading and writing files (which is around chapter 2 in any programming book / tutorial), then you will certainly have trouble with both graphics, and network communications.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Jan 20th, 2009, 02:10 PM
#8
Re: Load / Save Game Info
Hmm... he's right.
I suggest you just go to the library and get a big VB.NET book that will tell you all you need to know. (That's how I learned VB.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|