Visual Basic Tetris Game Help.?

flaminmonky

New member
I am trying to make Tetris in visual basic, but it isn't working. I'm trying to use an image array to stand for each of the picture boxes. My main problem is the loop. I put the timer at one millisecond but it takes way too long to be functional. The loop is made to make each of the items in the array to go into the cell below it. I put a code in there so it will hopefully stopped an above block from passes into another. This is not all the code. I have codes to give the image to picture boxes but that is not the problem, I don't think at least. Can anyone fix my problem?
Here is the code....


Public Class Form1

Private BlockArray(10, 18) As Image
Private Xint, Yint, ShapeInteger, RecordY As Integer
Private Block1 As Image = My.Resources.RedBlock11
Private Block2 As Image = My.Resources.BlueBlock1
Private Block3 As Image = My.Resources.GreenBlock1
Private Block4 As Image = My.Resources.PurpleBlock1
Private Block5 As Image = My.Resources.TurqouiseBlock1
Private Block6 As Image = My.Resources.BrownBlock1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Xint = 0
Yint = 1

Timer2.Start()

BlockArray(1, 3) = My.Resources.RedBlock11
BlockArray(2, 1) = My.Resources.RedBlock11

End Sub


Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick



Xint = 0

Do Until Xint = 10
Xint += 1
Yint = 17
Do Until Yint = 0
If BlockArray(Xint, Yint + 1) IsNot My.Resources.Rock3 Then
BlockArray(Xint, Yint + 1) = BlockArray(Xint, Yint)

Else
BlockArray(Xint, Yint) = My.Resources.Rock3
Xint = 0
RecordY = Yint
Do Until Xint = 10
Yint = 18
Xint += 1
Do Until Yint = 0
If BlockArray(Xint, Yint) Is My.Resources.RedBlock11 Then
BlockArray(Xint, Yint) = My.Resources.Rock3
End If
Yint -= 1
Loop
Loop
Yint = RecordY
End If
Yint -= 1
Loop
Loop

If BlockArray(1, 18) IsNot Nothing Then
BlockArray(1, 18) = My.Resources.Rock3
Xint = 0
Do Until Xint = 10
Yint = 18
Xint += 1
Do Until Yint = 0
If BlockArray(Xint, Yint) Is My.Resources.RedBlock11 Then
BlockArray(Xint, Yint) = My.Resources.Rock3
End If
Yint -= 1
Loop
Loop
End If
If BlockArray(2, 18) IsNot Nothing Then
BlockArray(2, 18) = My.Resources.Rock3
End If
If BlockArray(3, 18) IsNot Nothing Then
BlockArray(3, 18) = My.Resources.Rock3
End If
If BlockArray(4, 18) IsNot Nothing Then
BlockArray(4, 18) = My.Resources.Rock3
End If
If BlockArray(5, 18) IsNot Nothing Then
BlockArray(5, 18) = My.Resources.Rock3
End If
If BlockArray(6, 18) IsNot Nothing Then
BlockArray(6, 18) = My.Resources.Rock3
End If
If BlockArray(7, 18) IsNot Nothing Then
BlockArray(7, 18) = My.Resources.Rock3
End If
If BlockArray(8, 18) IsNot Nothing Then
BlockArray(8, 18) = My.Resources.Rock3
End If
If BlockArray(9, 18) IsNot Nothing Then
BlockArray(9, 18) = My.Resources.Rock3
End If
If BlockArray(10, 18) IsNot Nothing Then
BlockArray(10, 18) = My.Resources.Rock3
End If

BlockArray(1, 1) = Nothing
BlockArray(2, 1) = Nothing
BlockArray(3, 1) = Nothing
BlockArray(4, 1) = Nothing
BlockArray(5, 1) = Nothing
BlockArray(6, 1) = Nothing
BlockArray(7, 1) = Nothing
BlockArray(8, 1) = Nothing
BlockArray(9, 1) = Nothing
BlockArray(10, 1) = Nothing
 
Back
Top