Puzzle Game / Skill1.vb
![]() |
Puzzle Game - Skill1.vb |
Skill1.vb
- Public Class Skill1
- Dim MoveState As Integer = 0
- Dim MoveObject As Object
- Dim SkillPics As Integer = 0
- Dim CountIMG As Integer = 0
- Public Sub SetubCursor(ByVal MyImage As Bitmap)
- On Error Resume Next
- Dim bmCur As New Bitmap(MyImage)
- Dim ptrCur As IntPtr = bmCur.GetHicon
- Dim cur As Cursor
- cur = New Cursor(ptrCur)
- Me.Cursor = cur
- End Sub
- Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- SetubCursor(My.Resources.cursor_copy)
- Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
- Me.WindowState = FormWindowState.Maximized
- SkillPics = 9
- End Sub
- Private Sub MPic1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic1.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic1.Image)
- MoveObject = MPic1
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic2.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic2.Image)
- MoveObject = MPic2
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic3.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic3.Image)
- MoveObject = MPic3
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic4.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic4.Image)
- MoveObject = MPic4
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic5.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic5.Image)
- MoveObject = MPic5
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic9.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic9.Image)
- MoveObject = MPic9
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic6.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic6.Image)
- MoveObject = MPic6
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic7.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic7.Image)
- MoveObject = MPic7
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub MPic8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPic8.Click
- If MoveState = 0 Then
- MoveState = 1
- SetubCursor(MPic8.Image)
- MoveObject = MPic8
- MoveObject.visible = False
- Else
- MoveState = 0
- SetubCursor(My.Resources.cursor_copy)
- End If
- End Sub
- Private Sub Skill1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
- 'On Error Resume Next
- If MoveObject IsNot Nothing Then
- MoveObject.visible = True
- MoveObject.left = e.Location.X - MoveObject.width / 2
- MoveObject.top = e.Location.Y - MoveObject.height / 2
- Dim TargetPic As Object = Nothing
- If MoveObject.name = MPic2.Name Then
- TargetPic = Pic1
- ElseIf MoveObject.name = MPic1.Name Then
- TargetPic = Pic6
- ElseIf MoveObject.name = MPic3.Name Then
- TargetPic = Pic4
- ElseIf MoveObject.name = MPic4.Name Then
- TargetPic = Pic8
- ElseIf MoveObject.name = MPic5.Name Then
- TargetPic = Pic7
- ElseIf MoveObject.name = MPic9.Name Then
- TargetPic = Pic2
- ElseIf MoveObject.name = MPic6.Name Then
- TargetPic = Pic9
- ElseIf MoveObject.name = MPic7.Name Then
- TargetPic = Pic5
- ElseIf MoveObject.name = MPic8.Name Then
- TargetPic = Pic3
- Else
- TargetPic = Nothing
- End If
- If TargetPic IsNot Nothing And MoveObject.left > TargetPic.Left - 50 And MoveObject.top > TargetPic.Top - 50 And MoveObject.left < TargetPic.Left + TargetPic.Width And MoveObject.top < TargetPic.Top + TargetPic.Height Then
- MoveObject.location = TargetPic.Location
- Beep()
- Me.Text = "رائع ... في المكان الصحيح"
- SetubCursor(My.Resources.cursor_copy)
- CountIMG += 1
- If CountIMG >= SkillPics Then MsgBox("لقد ربحت") : Skill2.Show() : Me.Close()
- Else
- Me.Text = "لم تتطابق"
- SetubCursor(My.Resources.cursor1_copy)
- End If
- MoveObject = Nothing
- MoveState = 0
- End If
- End Sub
- End Class