|
|
|
|
|
|
|
|
:: Allcards :: JAVA applet
:: Delphi Guide |
|
Now, fill in playing area cells (field(8, 6) array) with random-number generator values. Calculate number of seconds in current time, and run the random-number generator cycle corresponding number of times:
TM = Time 'Get time TTMS = Len(TM) 'Time string lenght TTM = Mid$(TM, 7, 2) 'Extract seconds position For i = 0 To TTM ‘Repeat Form1.Caption = Int((20 * Rnd) + 1) ‘Print to Form1 caption Next i
The procedure looks like the following:
Private Sub Set_Nominal()
TM = Time 'Get time
TTMS = Len(TM) 'Time string lenght
TTM = Mid$(TM, 7, 2) 'Extract seconds position
For i = 0 To TTM 'Repeat
Form1.Caption = Int((20 * Rnd) + 1) ‘Print to Form1 caption
Next i '--------------------------------------------------
' fill in playing area cells field(8, 5)
For i = 0 To 7
For j = 0 To 4
field(i, j) = Int((20 * Rnd) + 1)
Next j
Next i
End Sub
Now a test procedure Private Sub Fdraw() can be written to see how field(8, 6) array is filled. The procedure Private Sub Fdraw() looks like the following: (see code) | |
|
|
|
|
I.e., every cell is recorded in each cell Caption. Such method is not to be considered as an optimal one; further on other programming methods can be used. To see the results it is necessary to insert two procedures call: Private Sub Set_Nominal() and Private Sub Fdraw() in a program autostart (for a while):
Private Sub Form_Load()
Set_Nominal
Fdraw
End Sub
A complete Visual Basic project of this game development stage is in the file vbg1.zip
Now it is necessary to create a procedure to analyze field(8, 6) array cell content, and depending on their values, to form a required symbol value (nominal) of a playing area cell and specify a required symbol and cell background colour.
Now, overwrite Fdraw() procedure in another one. Create another Label56 to temporarily store a generated cell nominal and its colour attributes (highlighted at the figure).
- Label56
Source code Private Sub Color_Chars() see here.
Now add copying values and Label56 cell attributes in the playing area cell, and use several cycles to process the whole field(8, 6) array:
- copying example
Label7.Caption = Label56.Caption
Label7.BackColor = Label56.BackColor
Label7.ForeColor = Label56.ForeColor
As a result there appears a nominal copying Sub Field_Fill() procedure from a responsible cell Label56, while a procedure Color_Chars() is changed in the following way - see code.
Such variant of filling a playing area with START values (at the start of the game) cannot be considered as an optimal one. However it is very demonstrable for algorithm understanding.
Form_Load() procedure looks like following:
Private Sub Form_Load()
Set_Nominal
Fdraw
Field_Fill
End Sub
To see how it works add another Form_Click() procedure (for a while, for the program debugging):
Private Sub Form_Click()
Set_Nominal ‘Fill array field(i,j)
Fdraw ‘Draw field(i,j) – for debug
Field_Fill ‘Print real nominals
End Sub
|
|
|
|
|
|
- it is absolutely identical to Form_Load() procedure
To draw real cell nominals and colour attributes. Now, clicking the mouse to Form1 field (only forms) you can see if the cell nominals values and their colour attributes are changed correctly.
A complete Visual Basic project of this game development stage is in the file vbg2.zip
Form_Click() procedure can be deleted.
Now develop Num_Move() procedure to overwrite playing area cells’ values and colour attributes in a row-wise top-down way and to fill a playing area top row with new values (i.e., new cell values are input in the game from the top row). The procedure contains copying operators. You can develop a more optimal copying algorithm.
Private Sub Num_Move()
For j = 0 To 4
For i = 0 To 7
field(i, j) = field(i, j + 1)
Next i
Next j
Field_Fill
End Sub
To see how top-down copying values and cell attributes works, create a temporary click handling procedure at Frame1:
Private Sub Frame1_Click()
Num_Move
End Sub
A complete Visual Basic project of this game development stage is in the file vbg3.zip
Now it necessary to add Private Sub Up_Str_App() code to fill in the playing area top row with new values - see code.
Attach the Frame1.Click procedure call
A complete Visual Basic project of this game development stage is in the file vbg4.zip
Click the mouse to the Frame1 field and see how it works!
Now it is necessary to write a handling code for player’s placing a game marker in any bottom row cell of the playing area.
(see next page)
|
|
|
|
|
|
|
|
Warning: All content on this website is free for none-commercial (personal) use. Game name, game algorithm, game forms and elements, game code is protected by copyright law and international treaties. Commercial reproduction must be licensed! Unauthorized commercial reproduction or distribution of this content, code and etc., or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law.
Copyright (c) by Valery V Shmeleff http://www.oflameron.ru |
|
|
|
|
|
Registered in Russian Federation RIPN 30 Nov 2001 |
|
|
|