01-12-2004, 11:57 PM
|
#5
|
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
You mean the assignment doc? It's in Dutch, but I'll translate.
Quote:
<snips out the rules of the game, as I guess you already know those>
2. Assignment
The assignment exists out of implementing the Four On A Row/Connect Four game in Visual Basic. In this section, you'll find a summing of what we expect of you concretely.
First you have to design the user interface. This needs to represent the playfield. Of course, the players have to be able to change something to the playfield. For this, the seen objects (buttons, labels, etc) will be used. An example of a layout can be found in image ?? <another example's the one in the zip-file I linked to earlier> You can also be a bit more creative and think up your own layout. The objects that have to be present, are derivable from the requirements we ask of your program.
The program has to agree to at least these criteria:
1) The playfield has to exist out of 7 columns and 6 rows. Each tile can for example exist out of a circular shape object
2) The game has to be able to be played by two human players. You don't have to apply a computerplayer.
3) The name and turn of the player whose turn it is has to be shown. You'll have to make it possible to give the names of the players before the game can start.
4) You need to make a method to drop a coin in a column (iow. coloring the tile). This can be realised by, for example, clicking a button above the column. The coin has to behave like written in the rules. The color of the coin is, of course, the color of the current player.
5) If a player has played a coin, the turn has to switch to the other player automatically. You can do this by showing the corresponding name or color of this player somewhere.
6) You also have to detect if a player has won. This has to be made known (for example with the aid of MsgBox). Also, if the board is full and no winner is appointed, you have to make this known. After one of these situations, a new game has to be started (like clearing the playfield). When these players don't want to play anymore, you have to apply the possibility to stop the game and enter new names.
7) For each of the two players, a score has to be kept. This exists out of the amount of times each player has won. The score is to be kept for a series of consecutive games that the same players play against each other. If a new game is started manually (with inputting the playernames), you can forget the old scores. You don't have to store anything in a file or the likes.
3) EXTRAS
<snips this out, as it just gives examples of extra stuff you can add, but which isn't necessary, and got a list of my own to add>
4) TIPS 'N TRICKS
1) Make sure your program is easy to understand. This is done by supplying enough comments in your code, along with choosing clear and meaningful names for your code-elements.
2) To come to a simple program, it is important to make the right choice of building the board. To come to a good choice here, here is a tip: Make use of a Control Array. You can concider this as a row with alot of objects of the same type and with the same name. A specific object inside this row can be called on* by putting the its number behind the rowname (vb. Buttons(5)). You make a Control Array like this:
* <snips>
The organisation of the fields can look like this:
5|* * 35* * * 36* * * 37* * * 38* * * 39* * * 40* * * 41
4|* * 28* * * 29* * * 30* * * 31* * * 32* * * 33* * * 34
3|* * 21* * * 22* * * 23* * * 24* * * 25* * * 26* * * 27
2|* * 14* * * 15* * * 16* * * 17* * * 18* * * 19* * * 20
1|* * 7* * * * 8* * * * 9* * * 10* * * 11* * * 12* * 13
0|* * 0* * * * 1* * * * 2* * * 3* * * * 4* * * * 5* * * 6
* ------------------------------------------------------
* * * * 0* * * * 1* * * * 2* * * * 3* * * 4* * * * 5* * * 6
The reacting to events of objects in a Control Array (e.g. a mouse-click) happens <yadayadayada, explanation of how to use Control Arrays>
3) To make the code more readable (which makes it easier to correct mistakes), you best do the following. Define 2 global variables: AMOUNT_ROWS and AMOUNT_COLUMS, which respectively represent the amount of rows and the amount of colums (so 6 and 7). Beware, the rows and columns start counting at 0. So the first row (column) is row (column) 0. With the aid of these formulas you can calculate the row and column if your Index is given:
r = Int(index / AMOUNT_COLUMNS)
k = Index mod AMOUNT_COLUMS
These formulas are best to be poured into separate modules, who'll take the index as an argument and returns the column - or rownumber as result. Better apply a methode which does the opposite too, nl. which returns the index of a given column- and rownumber.
You can easily check if a field is at the border of the playfield this way. For example to check if a field is at the right edge of the board, you do the following:
if k = AMOUNT_COLUMNS-1 Then
...
Else
...
EndIf
You can define yet other methodes who'll make the working with indexes easier the same way. Think especially of the controling of the diagonals.
5.
<Snips, as it's some practical stuff, like when to hand it in (friday before noon), and how, and where>
|
|
                       
|
|