Shaq32
09-09-2009, 03:00 PM
I'm making a Tetris game for school, and I'm having a problem with stopping the shapes. Whenever I have a shape come down, I clear the form and repaint all the shapes back onto the form. Then I check boundaries around image1(image1.ubound) (the shape that is falling) by using GetPixel. Instead of just having one point on the bottom to check for a collision, I'm trying to loop through every pixel from the .left of the block to the .right of the block, and use the .top + .height for the Y value. I tried a couple different ways and I just can't get this working. I know something about this is wrong and I really need help.
Private Sub checkBoundaryColors()
With Image1(Image1.UBound)
For i = .Left To .Left + .Width - 2
shapeColorBottom = GetPixel(Me.hdc, i, .Top + .Height)
Select Case shapeColorBottom
Case DARK_GREY, LIGHT_GREY, GREY_LINES
'if the color around the shape is gray, it will move since it isn't
' touching a wall or another shape
.Top = .Top + MOVE_ONE_BLOCK
Case Else
'when a shape stops on another shape or the bottom, it changes to a darker color
Image1(Image1.UBound).Picture = LoadPicture(App.Path & "\Images\Dark Shapes\Dark " & shape & " " & shapeCounter & ".gif")
Call dropShape
End Select
Next i
End With
End Sub
I also uploaded the program itself if you want to see the whole thing and figure out what needs to be done.
Thanks :)
Private Sub checkBoundaryColors()
With Image1(Image1.UBound)
For i = .Left To .Left + .Width - 2
shapeColorBottom = GetPixel(Me.hdc, i, .Top + .Height)
Select Case shapeColorBottom
Case DARK_GREY, LIGHT_GREY, GREY_LINES
'if the color around the shape is gray, it will move since it isn't
' touching a wall or another shape
.Top = .Top + MOVE_ONE_BLOCK
Case Else
'when a shape stops on another shape or the bottom, it changes to a darker color
Image1(Image1.UBound).Picture = LoadPicture(App.Path & "\Images\Dark Shapes\Dark " & shape & " " & shapeCounter & ".gif")
Call dropShape
End Select
Next i
End With
End Sub
I also uploaded the program itself if you want to see the whole thing and figure out what needs to be done.
Thanks :)