The construction of Tetris in the past two days is a complicated one. It is implemented in several steps.
HereSeveral types of deformation of blocks are implemented using VB, and the movement of blocks is controlled using the direction keys.
Sub new_block (inttype as integer)
Select case inttype
Case 1
Block (0). Left = block (0). Width * 0
Block (0). Top = block (0). Height * 0
Block (1). Left = block (0). Width * 1
Block (1). Top = block (0). Height * 0
Block (2). Left = block (0). Width * 2
Block (2). Top = block (0). Height * 0
Block (3). Left = block (0). Width * 3
Block (3). Top = block (0). Height * 0
Case 2
Block (0). Left = block (0). Width * 0
Block (0). Top = block (0). Height * 0
Block (1). Left = block (0). Width * 1
Block (1). Top = block (0). Height * 0
Block (2). Left = block (0). Width * 0
Block (2). Top = block (0). Height * 1
Block (3). Left = block (0). Width * 1
Block (3). Top = block (0). Height * 1
Case 3
Block (0). Left = block (0). Width * 1
Block (0). Top = block (0). Height * 0
Block (1). Left = block (0). Width * 0
Block (1). Top = block (0). Height * 1
Block (2). Left = block (0). Width * 1
Block (2). Top = block (0). Height * 1
Block (3). Left = block (0). Width * 2
Block (3). Top = block (0). Height * 1
Case else
Block (0). Left = block (0). Width * 0
Block (0). Top = block (0). Height * 0
Block (1). Left = block (0). Width * 1
Block (1). Top = block (0). Height * 0
Block (2). Left = block (0). Width * 2
Block (2). Top = block (0). Height * 0
Block (3). Left = block (0). Width * 3
Block (3). Top = block (0). Height * 0
End select
Dim I as integer
For I = 0 to 3
Block (I). Visible = true
Next
End sub
_________________________________________________
Sub block_move (FX as integer)
Dim I as integer
Dim X as integer
Dim y as integer
If can_move (FX) = false then
Exit sub
End if
For I = 0 to 3
X = block (I). Left/block (I). Width
Y = block (I). Top/block (I). Height
Select case FX
Case 1
X = x-1
Case 2
Y = Y-1
Case 3
X = x + 1
Case 4
Y = Y + 1
End select
Block (I). Left = block (I). Width * x
Block (I). Top = block (I). Height * y
Next
End sub
_________________________________________________
Private sub commandementclick ()
If isnumeric (text1.text) then
New_block CINT (text1.text)
End if
End sub
_________________________________________________
Private sub file_keydown (keycode as integer, shift as integer)
Block_move keycode-36
End sub
_________________________________________________
Function can_move (FX as integer) as Boolean
Dim I as integer
Dim X as integer
Dim y as integer
Can_move = true
For I = 0 to 3
X = block (I). Left/block (I). Width
Y = block (I). Top/block (I). Height
Select case FX
Case 1
X = x-1
Case 2
Y = Y-1
Case 3
X = x + 1
Case 4
Y = Y + 1
End select
If x <0 or x> 9 or Y <0 or Y> 14 then
Can_move = false
Exit Function
End if
Next
End Function