...

View Full Version : Visual Basic Help



Saphr0ne
10-01-2012, 12:09 AM
So I'm making a console ASCII sandbox game in VB, and I've come to a problem. I want there to be a randomly generated world when you start the game, and the worlds are made like this:


7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,6,6,6,6,6,6,6,6,6,6,6,6,6
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,8,6,6,6,6,6,6,6,6,6,6,6,6
7,7,7,7,1,1,1,1,1,1,1,1,1,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,8,6,6,6,6,6,6,6,6,6
7,7,7,7,1,0,0,0,0,0,0,0,0,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,8,6,6,6,6,6,6,6,6
7,7,7,7,1,0,0,0,0,0,0,0,0,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,6,6,6,6,6,6,6,6
7,7,7,7,1,0,0,0,0,0,0,0,0,1,7,7,7,7,7,7,7,7,7,7,7,7,5,5,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,6,6,6,6,6,6,6,6
7,7,7,7,1,0,0,0,0,0,0,0,0,1,7,7,7,7,7,7,7,7,7,7,7,7,5,9,5,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,6,6,6,6,6,6,6,6
7,7,7,7,1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,7,7,7,7,7,6,6
7,7,7,7,7,7,7,7,7,5,5,5,9,5,9,5,5,5,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,5,5,5,9,5,5,5,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
7,7,7,7,7,7,7,7,7,7,5,5,5,5,5,9,5,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,5,5,5,5,5,5,5,5,5,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,5,5,5,9,5,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,5,5,5,5,5,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7

And I've added this bit of code to my main.vb to generate a random conglomeration of the numbers above in the same 64x22 pattern.


Dim rnd As New Random

For x = 0 To 64
For y = 0 To 20
Dim RndNo As Integer = rnd.Next(0, 8)
cCon.WriteToBuffer(RndNo)
Next
Next

But currently it just writes all those numbers to the console before the game starts up, and I have no idea how to make it write to a file that needs to be called "world.map", because after that bit of code, the MapParser reads world.map to start the game.

Not only that, but I also need it to add the commas. Can anyone help?

Here's a download link if you want to look into the files yourself because my explanations are awful: http://www.sendspace.com/file/ob36ah

Thanks :D

alykins
10-01-2012, 02:28 PM
See if you can get some info out of these links...
File Class (http://msdn.microsoft.com/en-us/library/system.io.file.aspx#Y0)
StreamWriter Class (http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx)

You may want to make a file folder in the C:\ drive to save to, sometimes permissions get hairy when you try to write to C:\.

Play with that some and post back if you still can't get it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum