|
[ Page 2 ]
[ Russian Game ] |
Get Links at SubmitLinksFree.com, the online directory for high quality websites.Visual Basic Tutorial |
Download |
![]() [-1,-5,-10,-15,-25] - deduct the indicated points from your account. [1,5,10,15,25] - add the indicated points to your account. [B] - deducts 200 points from your account. [P] - adds 100 points to your account. [T] - adds 500 points to your account. [Z] - zeroes your account. [END] - ends the game. ![]() ![]() 1 – put “marker” on any cell of the game field bottom line only once at the game start (by clicking on the cell field). 2 – on putting the “marker”, the player can move it right or left along the game field bottom line by means of left and right arrows (keyboard button). ![]() ![]() ![]() ![]() ![]() ![]() GAME Programming
|
Brief description of a VB version game |
![]() ![]() and the nominal of the cell occupied is added to or subtracted from a player’s score. A lower colour linear indicator ![]() The game score is tracked in an orange cell: ![]() The game goes on until a player’s score equals to zero or the marker gets into a cell with an |End| nominal. |
The game is not as simple as it may seem. It is very easy to move a marker to the cells |Z| (score mulling) or |End| (end of the game). Here a programming process of a “text-only version” of a logical tabular game "Oflameron" is described. The cell nominals are presented at the screen as symbols, while the cells are Label elements. 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) ![]() 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). ![]() ![]() 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 ![]() 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. |
![]() Private Sub Save_Color() savecolor(0) = Label7.BackColor 'Save bgcolor Label7 savecolor(1) = Label8.BackColor 'Save bgcolor Label8 savecolor(2) = Label9.BackColor 'Save bgcolor Label9 savecolor(3) = Label10.BackColor 'Save bgcolor Label10 savecolor(4) = Label11.BackColor 'Save bgcolor Label11 savecolor(5) = Label12.BackColor 'Save bgcolor Label12 savecolor(6) = Label13.BackColor 'Save bgcolor Label13 savecolor(7) = Label14.BackColor 'Save bgcolor Label14 End Sub Create a trigger firstset = 0 Trigger=0, if a marker has not been placed in the bottom row yet. General code fragment that handles marker placing in the bottom row - see code. ![]() Save_Color() procedure is used to restore cell colour when moving the marker horizontally (along the bottom row of the playing area). Create a markersave variable to memorize an array ELEMENT NUMBER savecolor(j), the variable corresponding to the marker cell (i.e. the cell, in which the marker has been placed). The possibility of placing a marker on one cell only can be checked. Now it is necessary to provide a marker being saved (in terms of cell turning blue) when shifting cells top – down. The procedure of marker colour restoring after playing area cells shifting top-down: Private Sub Marker_Reset() If markersave = 0 Then Label7.BackColor = &HFF0000 If markersave = 1 Then Label8.BackColor = &HFF0000 If markersave = 2 Then Label9.BackColor = &HFF0000 If markersave = 3 Then Label10.BackColor = &HFF0000 If markersave = 4 Then Label11.BackColor = &HFF0000 If markersave = 5 Then Label12.BackColor = &HFF0000 If markersave = 6 Then Label13.BackColor = &HFF0000 If markersave = 7 Then Label14.BackColor = &HFF0000 End Sub Now activate Marker_Reset() procedure to operate in a top-down shift procedure. In the bottom of Frame1_Click() procedure insert the following code (marked as underline): Private Sub Frame1_Click() Num_Move 'Shift the values of all rows one row down Up_Str_App 'Fill in the top row with new nomimals Marker_Reset 'Marker redraw End Sub A complete Visual Basic project of this game development stage is in the file vbg5.zip Write a score count procedure when placing a marker in the beginning of the game - see code. Now attach a score count procedure in each of click procedures for bottom row cells: Private Sub Label7_Click() If firstset = 0 Then Save_Color 'Save bgcolor If firstset = 0 Then Label7.BackColor = &HFF0000 'Set new bgcolor (blue) If firstset = 0 Then firstset = 1 'No use again markersave = 0 Set_Marker_Count ‘Rewrite counter End Sub For other bottom row cells the procedure is exactly the same. Now write a score counting procedure at cells’ shifting top-down. Procedure looks like extremely simple: Private Sub Dn_Count() |
n = 0 ‘Temporarily to resolve work of procedure Set_Marker_Count
Set_Marker_Count ‘Procedure of calculation of glasses after installation of a marker End Sub To demonstrate the procedure operation, insert the procedure call in a top-down cell row shifting procedure Frame1_Click(): Private Sub Frame1_Click() Num_Move 'To move values of all cells from above - downwards Up_Str_App 'To fill in the top line of a game field new values Marker_Reset 'Rewrite marker Dn_Count 'To count up glasses at moving lines from above - downwards End Sub A complete Visual Basic project of this game development stage is in the file vbg6.zip Create a procedure of linear colour indicator operation. Add Timer1 to the form and enable it at once. see code. You can see how the indicator works. Now you should disable the timer and enable it after the market has been placed in a playing area bottom row. Insert timer enabling in a marker placing procedure in a playing area bottom row (to be more exact – in a score counting procedure after marker placing Set_Marker_Count(), since the procedure is common for all cells of a lower level). At the end of the procedure Set_Marker_Count() there is a line: Timer1.Enabled = True 'The timer is ON since the marker is put A complete Visual Basic project of this game development stage is in the file vbg7.zip When a linear colour indicator disappears completely, it is necessary to shift down all rows with playing area cells (Frame1_Click() procedure) to the marker, count scores and fill in a playing area top row with new nominal values. Timer1 operation procedure looks like the following way: Private Sub Timer1_Timer() IndLent = IndLent + 1 If IndLent = 9 Then IndLent = 0 Timer1.Interval = 500 Frame1_Click 'To move levels End If Print_Ind 'Draw indicator End Sub Keyboard Now it is necessary to write handling of pressing down the key and marker’s moving to the [right] / [left] ![]() Place another timer (Timer2) at Form1. Set a time interval Timer2 = 50 and place a key status test code in a printer operation procedure. Declare procedure operation functions: Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer And a handling code as such - see code. Inscriptions in Left and Right form header are presented only for debugging purposes. Markersave variable shows a unique playing area bottom row cell that contains a marker. Write a procedure of marker moving to the left / right along the bottom row - see code. Now it is necessary to create only one procedure – a procedure of shifting the numbering of current gaming level |Level|: Private Sub Level_Count() Label6.Caption = Label6.Caption + 1 Label5.Caption = Label6.Caption + 1 Label4.Caption = Label5.Caption + 1 Label3.Caption = Label4.Caption + 1 Label2.Caption = Label3.Caption + 1 End Sub Attach a shifting procedure to the operations, for example: Private Sub Dn_Count() n = 0 Set_Marker_Count Level_Count 'Move Level End Sub A complete Visual Basic project of this game development stage is in the file vbg8.zip [ Make EXE file ] Now, this is a demonstrative moment: all software-realization procedures of the game Oflameron are ready. In other words, you have created a completely operable logical gaming program in Visual Basic. It is still early to introduce it as a commercial product as it still contains many faults. For example, when clicking the Frame object the game starts without placing the marker. Removing such faults and configuring the game as a commercial product are dealt in the 2nd & 3d parts of the guidelines. One of the 2nd parts variants (with system of bonuses , variants of complication of game , connect to Internet) - in file vbg15.zip ![]() ee@oflameron.ru Online trading exchange market - Trade, Exchange, Swap and Barter without any cost or obligations. |
|