Working with Classes and Properties for Game Development in VB.NET
(Page 1 of 4 )
We've covered console input and output, variables, conditionals, loops, arrays and collections. With these tools, we're finally ready to begin constructing our game, whose basic plan we looked at in the first article of this series. It's been a while (this is the sixth of nine parts), so if you need a refresher, feel free to go back to the first article to take another look at the plan.
Setting Up the Window
Here's what we should have right now:
Module Game
Sub Main()
End Sub
End Module
The first thing we need to do is set up the console window for our game. We need to give the window a proper size so that the interface fits on the screen, and we also need to give our game a title. I'm going to use the title "VB Quest," but feel free to use your own, more creative title. This code goes right at the top of Main:
Console.Title = "VB Quest"
Console.SetWindowSize(80, 35)
You can see what the window looks like by placing a call to ReadKey at the bottom. This will keep the window open until a key is pressed. If we set the window size to too small of a size, then the terminal window will scroll down, and the top lines of our game will not be visible.
When the user runs the game, he may have started execution by typing the name of the program into the console. If this is the case, there will be some text in the console already. We don't want anything to be in the console window already, so let's clear anything that might be there:
Console.Clear()
When the user opens the application, the first thing we need to do is welcome him to the game. This is easy. A short sentence will do, unless you feel artistic and want to decorate it somehow (maybe add some color?-you know how):
Console.WriteLine("Welcome to VB Quest.")
Then we need to ask him his name. This is also easy:
Console.WriteLine("What is your name?")
Console.Write(" >")
Dim name As String = Console.ReadLine()
Next: Creating an Adventurer Class >>
More Visual Basic.NET Articles
More By Peyton McCullough