Public Class Pacman_Games
Dim moves As Integer = 0
Dim lblock As Integer = 0
Dim rblock As Integer = 0
Dim ublock As Integer = 0
Dim dblock As Integer = 0
Sub beweger()
If moves = 1 Then
If rblock = 0 Then
pacman.Left += 10
End If
End If
If moves = 2 Then
If lblock = 0 Then
pacman.Left -= 10
End If
End If
If moves = 3 Then
If ublock = 0 Then
pacman.Top -= 10
End If
End If
If moves = 4 Then
If dblock = 0 Then
pacman.Top += 10
End If
End If
Call wall()
End Sub
Private Sub Pacman_Games_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Windows.Forms.Keys.Up Then
moves = 3
End If
If e.KeyCode = Windows.Forms.Keys.Left Then
moves = 2
End If
If e.KeyCode = Windows.Forms.Keys.Right Then
moves = 1
End If
If e.KeyCode = Windows.Forms.Keys.Down Then
moves = 4
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = pacman.Location.X
Label2.Text = pacman.Location.y
Call beweger()
Call wall()
End Sub
Sub wall()
'อันนี้ผมลองเซทดูมันไม่ได้ครับ
'If pacman.Right = p2.Left Or pacman.Right = w1.Left And pacman.Bottom > w1.Top And pacman.Top < w1.Bottom Then
rblock = 1
Else
rblock = 0
End If
End Sub
End Class
Tag : .NET, VBScript, VB.NET
Date :
2012-09-14 10:20:15
By :
showroom
View :
1119
Reply :
4
No. 1
Guest
แบบนี้ต้องวนลูปแล้ว check collision แล้ว
พอกดปุ่มทีก็เช็คการชนทีนึง ใช้วนลูปเอา โดยใช้ position กับ width, height ตรวจสอบ