Wednesday, 6 May 2015

Make A Visual Basic Game

Make a Visual Basic Game


Microsoft Visual Basic is a basic programming language, ideal for those just learning to program. The learning curve on Visual Basic is not as steep on other coding languages, as the entire program does not need to be generated using code. Visual Basic allows the creator to assemble a visual representation of their program by placing elements, such as text boxes, buttons and pictures, then write code behind the scenes to operate the elements, as opposed to other languages where the placement of elements must also be coded.


Instructions


1. Open Visual Basic and click "File" then "New" to begin a new game project, or click "File" then "Open" to continue working on a previous game project.


2. Adjust the size of the main window of your game. The size can be adjusted by clicking on the lower right corner of the window then dragging the corner until it is your desired size. The window size can also be adjusted numerically by clicking on a portion of the game window which does not have an element on it, then adjusting the Height and Width dimensions in the element properties window.


3. Insert visual elements into your game as needed. For Tic Tac Toe, for example, you will want 9 picture boxes, in the form of a 3 by 3 grid. Additionally, you would want 4 lines, to make up the grid of the Tic Tac Toe game, and a pair of labels to keep track of how many games have been won by Player 1 and how many games have been won by Player 2.


4. Declare variables for your game. Variables declared as global can be used between any windows in your project, if your game includes more than one. Variables declared as local can be used between all the elements of a single window. Undeclared variables can not be passed between elements. Any undeclared variable used in an element will start out with a non-value as a string, and a numerical value of 0.


5. Use arrays to simplify your coding, saving you writing time and making the game run more efficiently. With Tic Tac Toe, for example, a 3 by 3 array can be used. When checking for a winner, loops can be used with the array to test all of the possible winning combinations in only a few lines, whereas it would require significantly more lines of code if each of the 9 boxes had its own individually named variable.


6. Code the actions of your visual elements. With Tic Tac Toe you would want to add code for each of the picture element's under the "Click" action, which would look like "Row1Column1_Click()" to change the value of the corresponding variable of that box to either "X" or "O" and to change the picture to a picture of an X or an O.

Tags: Visual Basic, your game, Basic Game, been Player, between elements, click File, click File then