my project havent work
Posted: Wed Jun 19, 2013 7:17 pm
i want that the invader change the Direction when he see wall and dont every time dunnno; tnx
Public Class level2for
Dim gen As New Random
Dim SRight As Boolean 'pucman moving right
Dim SLeft As Boolean 'pucman moving left
Dim SUp As Boolean 'pucman moving up
Dim SBot As Boolean 'pucman moving bot
Dim IMOVE As Integer
Dim invaderup As Boolean = False
Dim invaderdown As Boolean = False
Dim invaderleft As Boolean = False
Dim invaderright As Boolean = False
Dim Ilblock As Integer = 1
Dim Irblock As Integer = 1
Dim Iublock As Integer = 1
Dim Idblock As Integer = 1
Dim lblock As Integer = 1
Dim rblock As Integer = 1
Dim ublock As Integer = 1
Dim dblock As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
IMOVE = gen.Next(1, 5)
Call invader_wall()
Call invader_movewill()
Call invader_move()
End Sub
Private Sub level1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Audio.Play(My.Resources.food, AudioPlayMode.BackgroundLoop) 'to make the song run
End Sub
Sub invader_wall()
If invader.Right = p2.Left Or invader.Right = w1.Left And invader.Bottom > w1.Top And invader.Top < w1.Bottom Or invader.Right = w2.Left And invader.Bottom > w2.Top And invader.Top < w2.Bottom Or invader.Right = w3.Left And invader.Bottom > w3.Top And invader.Top < w3.Bottom Or invader.Right = w4.Left And invader.Bottom > w4.Top And invader.Top < w4.Bottom Or invader.Right = w5.Left And invader.Bottom > w5.Top And invader.Top < w5.Bottom Or invader.Right = w6.Left And invader.Bottom > w6.Top And invader.Top < w6.Bottom Then
Irblock = 1 'check if there is wall where is invader is going
Else
Irblock = 0
End If
If invader.Left = p4.Right Or invader.Left = w1.Right And invader.Bottom > w1.Top And invader.Top < w1.Bottom Or invader.Left = w2.Right And invader.Bottom > w2.Top And invader.Top < w2.Bottom Or invader.Left = w3.Right And invader.Bottom > w3.Top And invader.Top < w3.Bottom Or invader.Left = w4.Right And invader.Bottom > w4.Top And invader.Top < w4.Bottom Or invader.Left = w5.Right And invader.Bottom > w5.Top And invader.Top < w5.Bottom Or invader.Left = w6.Right And invader.Bottom > w6.Top And invader.Top < w6.Bottom Then
Ilblock = 1 'check if there is wall where is invader is going
Else
Ilblock = 0
End If
If invader.Top = p1.Bottom Or invader.Top = w1.Bottom And invader.Right > w1.Left And invader.Left < w1.Right Or invader.Top = w2.Bottom And invader.Right > w2.Left And invader.Left < w2.Right Or invader.Top = w3.Bottom And invader.Right > w3.Left And invader.Left < w3.Right Or invader.Top = w4.Bottom And invader.Right > w4.Left And invader.Left < w4.Right Or invader.Top = w5.Bottom And invader.Right > w5.Left And invader.Left < w5.Right Or invader.Top = w6.Bottom And invader.Right > w6.Left And invader.Left < w6.Right Then
Iublock = 1 'check if there is wall where is invader is going
Else
Iublock = 0
End If
If invader.Bottom = p3.Top Or invader.Bottom = w1.Top And invader.Right > w1.Left And invader.Left < w1.Right Or invader.Bottom = w2.Top And invader.Right > w2.Left And invader.Left < w2.Right Or invader.Bottom = w3.Top And invader.Right > w3.Left And invader.Left < w3.Right Or invader.Bottom = w4.Top And invader.Right > w4.Left And invader.Left < w4.Right Or invader.Bottom = w5.Top And invader.Right > w5.Left And invader.Left < w5.Right Or invader.Bottom = w6.Top And invader.Right > w6.Left And invader.Left < w6.Right Then
Idblock = 1 'check if there is wall where is invader is going
Else
Idblock = 0
End If
End Sub
Sub invader_movewill()
If IMOVE = 1 Then
If Irblock = 0 Then
invaderup = False
invaderdown = False
invaderleft = False
invaderright = True
End If
End If
If IMOVE = 2 Then
If Ilblock = 0 Then
invaderup = False
invaderdown = False
invaderleft = True
invaderright = False
End If
End If
If IMOVE = 3 Then
If Iublock = 0 Then
invaderup = True
invaderdown = False
invaderleft = False
invaderright = False
End If
End If
If IMOVE = 4 Then
If Idblock = 0 Then
invaderup = False
invaderdown = True
invaderleft = False
invaderright = False
End If
End If
End Sub
Sub invader_move()
If invaderup = False And
invaderdown = True And
invaderleft = False And
invaderright = False Then
invader.Top += 10 'make Invader move 10 cen down
End If
If invaderup = True And
invaderdown = False And
invaderleft = False And
invaderright = False Then
invader.Top -= 10 'make Invader move 10 cen down
End If
If invaderup = False And
invaderdown = True And
invaderleft = False And
invaderright = True Then
invader.Left += 10 'make Invader move 10 cen down
End If
If invaderup = False And
invaderdown = False And
invaderleft = True And
invaderright = False Then
invader.Left -= 10 'make Invader move 10 cen down
End If
invaderup = False
invaderdown = False
invaderleft = False
invaderright = False
End Sub
End Class
Public Class level2for
Dim gen As New Random
Dim SRight As Boolean 'pucman moving right
Dim SLeft As Boolean 'pucman moving left
Dim SUp As Boolean 'pucman moving up
Dim SBot As Boolean 'pucman moving bot
Dim IMOVE As Integer
Dim invaderup As Boolean = False
Dim invaderdown As Boolean = False
Dim invaderleft As Boolean = False
Dim invaderright As Boolean = False
Dim Ilblock As Integer = 1
Dim Irblock As Integer = 1
Dim Iublock As Integer = 1
Dim Idblock As Integer = 1
Dim lblock As Integer = 1
Dim rblock As Integer = 1
Dim ublock As Integer = 1
Dim dblock As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
IMOVE = gen.Next(1, 5)
Call invader_wall()
Call invader_movewill()
Call invader_move()
End Sub
Private Sub level1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Audio.Play(My.Resources.food, AudioPlayMode.BackgroundLoop) 'to make the song run
End Sub
Sub invader_wall()
If invader.Right = p2.Left Or invader.Right = w1.Left And invader.Bottom > w1.Top And invader.Top < w1.Bottom Or invader.Right = w2.Left And invader.Bottom > w2.Top And invader.Top < w2.Bottom Or invader.Right = w3.Left And invader.Bottom > w3.Top And invader.Top < w3.Bottom Or invader.Right = w4.Left And invader.Bottom > w4.Top And invader.Top < w4.Bottom Or invader.Right = w5.Left And invader.Bottom > w5.Top And invader.Top < w5.Bottom Or invader.Right = w6.Left And invader.Bottom > w6.Top And invader.Top < w6.Bottom Then
Irblock = 1 'check if there is wall where is invader is going
Else
Irblock = 0
End If
If invader.Left = p4.Right Or invader.Left = w1.Right And invader.Bottom > w1.Top And invader.Top < w1.Bottom Or invader.Left = w2.Right And invader.Bottom > w2.Top And invader.Top < w2.Bottom Or invader.Left = w3.Right And invader.Bottom > w3.Top And invader.Top < w3.Bottom Or invader.Left = w4.Right And invader.Bottom > w4.Top And invader.Top < w4.Bottom Or invader.Left = w5.Right And invader.Bottom > w5.Top And invader.Top < w5.Bottom Or invader.Left = w6.Right And invader.Bottom > w6.Top And invader.Top < w6.Bottom Then
Ilblock = 1 'check if there is wall where is invader is going
Else
Ilblock = 0
End If
If invader.Top = p1.Bottom Or invader.Top = w1.Bottom And invader.Right > w1.Left And invader.Left < w1.Right Or invader.Top = w2.Bottom And invader.Right > w2.Left And invader.Left < w2.Right Or invader.Top = w3.Bottom And invader.Right > w3.Left And invader.Left < w3.Right Or invader.Top = w4.Bottom And invader.Right > w4.Left And invader.Left < w4.Right Or invader.Top = w5.Bottom And invader.Right > w5.Left And invader.Left < w5.Right Or invader.Top = w6.Bottom And invader.Right > w6.Left And invader.Left < w6.Right Then
Iublock = 1 'check if there is wall where is invader is going
Else
Iublock = 0
End If
If invader.Bottom = p3.Top Or invader.Bottom = w1.Top And invader.Right > w1.Left And invader.Left < w1.Right Or invader.Bottom = w2.Top And invader.Right > w2.Left And invader.Left < w2.Right Or invader.Bottom = w3.Top And invader.Right > w3.Left And invader.Left < w3.Right Or invader.Bottom = w4.Top And invader.Right > w4.Left And invader.Left < w4.Right Or invader.Bottom = w5.Top And invader.Right > w5.Left And invader.Left < w5.Right Or invader.Bottom = w6.Top And invader.Right > w6.Left And invader.Left < w6.Right Then
Idblock = 1 'check if there is wall where is invader is going
Else
Idblock = 0
End If
End Sub
Sub invader_movewill()
If IMOVE = 1 Then
If Irblock = 0 Then
invaderup = False
invaderdown = False
invaderleft = False
invaderright = True
End If
End If
If IMOVE = 2 Then
If Ilblock = 0 Then
invaderup = False
invaderdown = False
invaderleft = True
invaderright = False
End If
End If
If IMOVE = 3 Then
If Iublock = 0 Then
invaderup = True
invaderdown = False
invaderleft = False
invaderright = False
End If
End If
If IMOVE = 4 Then
If Idblock = 0 Then
invaderup = False
invaderdown = True
invaderleft = False
invaderright = False
End If
End If
End Sub
Sub invader_move()
If invaderup = False And
invaderdown = True And
invaderleft = False And
invaderright = False Then
invader.Top += 10 'make Invader move 10 cen down
End If
If invaderup = True And
invaderdown = False And
invaderleft = False And
invaderright = False Then
invader.Top -= 10 'make Invader move 10 cen down
End If
If invaderup = False And
invaderdown = True And
invaderleft = False And
invaderright = True Then
invader.Left += 10 'make Invader move 10 cen down
End If
If invaderup = False And
invaderdown = False And
invaderleft = True And
invaderright = False Then
invader.Left -= 10 'make Invader move 10 cen down
End If
invaderup = False
invaderdown = False
invaderleft = False
invaderright = False
End Sub
End Class