Dim Score As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim delayLaser As Integer
'S/s to move ship right
If (KeyAscii = 84 Or KeyAscii = 115) And imgChar.Left < 4560 Then
imgChar.Left = imgChar.Left + 400
End If
'A/a moves ship left
If (KeyAscii = 65 Or KeyAscii = 97) And imgChar.Left > -150 Then
imgChar.Left = imgChar.Left - 400
End If
'For the SpaceBar
If KeyAscii = 32 Then
imgLaser1.Top = imgChar.Top - 400
imgLaser1.Left = imgChar.Left + 1120
For delayLaser = 1 To 20000
imgLaser1.Top = imgLaser1.Top - 4
Next delayLaser
hold = DoEvents
End If
End Sub
Private Sub MnuEExit_Click()
End
End Sub
Private Sub mnuLEasy_Click()
' hMove and vMove record the number of steps
' through each section of the animation
Dim hMove1 As Integer
Dim vMove1 As Integer
Dim hMove2 As Integer
Dim vMove2 As Integer
Dim hMove3 As Integer
Dim vMove3 As Integer
Dim hMove4 As Integer
Dim vMove4 As Integer
Dim enemyDelay As Long
Dim reset As Boolean
' position the Enemy Object(s)
imgEnemy1.Top = 0
imgEnemy1.Left = 0
'Rate at which the the enemy will move horizontally
hMove1 = 5
hMove2 = 5
hMove3 = 5
hMove4 = 5
'When Enemy Reaches at the edge it will add its own height and move down
vMove1 = 1095
vMove2 = 1095
vMove3 = 1095
vMove4 = 1095
'Mode When everything has to start
continue = "yes"
'While Continue = "yes" things will start in the loop
While continue = "yes"
reset = False
' pause to allow motion to be seen
For enemyDelay = 1 To 40000
Next enemyDelay
' move the Enemy object by adding 5 twips at a time
imgEnemy1.Left = imgEnemy1.Left + hMove1
imgEnemy2.Left = imgEnemy2.Left + hMove2
imgEnemy3.Left = imgEnemy3.Left + hMove3
imgEnemy4.Left = imgEnemy4.Left + hMove4
'This will check if image is at the edge of the screen
If imgEnemy1.Left = 6440 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start subtracting twips
hMove1 = hMove1 * -1
'Add height in twips, that way the image will move down
imgEnemy1.Top = imgEnemy1.Top + vMove1
'Checking if the .Left is at the left side of screen
ElseIf imgEnemy1.Left = 0 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start adding twips
hMove1 = hMove1 * -1
'Add height in twips, that way image will move down
imgEnemy1.Top = imgEnemy1.Top + vMove1
End If
If imgEnemy1.Top > 4320 Then
continue = "no"
reset = True
End If
If imgEnemy2.Left = 6440 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start subtracting twips
hMove2 = hMove2 * -1
'Add height in twips, that way the image will move down
imgEnemy2.Top = imgEnemy2.Top + vMove2
'Checking if the .Left is at the left side of screen
ElseIf imgEnemy2.Left = 0 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start adding twips
hMove2 = hMove2 * -1
'Add height in twips, that way image will move down
imgEnemy2.Top = imgEnemy2.Top + vMove2
End If
If imgEnemy2.Top > 4320 Then
continue = "no"
reset = True
End If
If imgEnemy3.Left = 6440 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start subtracting twips
hMove3 = hMove3 * -1
'Add height in twips, that way the image will move down
imgEnemy3.Top = imgEnemy3.Top + vMove3
'Checking if the .Left is at the left side of screen
ElseIf imgEnemy3.Left = 0 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start adding twips
hMove3 = hMove3 * -1
'Add height in twips, that way image will move down
imgEnemy3.Top = imgEnemy3.Top + vMove3
End If
If imgEnemy3.Top > 4320 Then
continue = "no"
reset = True
End If
If imgEnemy4.Left = 6440 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start subtracting twips
hMove4 = hMove4 * -1
'Add height in twips, that way the image will move down
imgEnemy4.Top = imgEnemy4.Top + vMove4
'Checking if the .Left is at the left side of screen
ElseIf imgEnemy4.Left = 0 Then
'If it is then it will change whehter twips will be added or subtracted
'In this case it is going to start adding twips
hMove4 = hMove4 * -1
'Add height in twips, that way image will move down
imgEnemy4.Top = imgEnemy4.Top + vMove4
End If
If imgEnemy4.Top > 4320 Then
continue = "no"
reset = True
End If
hold = DoEvents
'When Laser touches area of enemy's top and left
If imgLaser1.Top = (imgEnemy1.Top + 1000) And (imgLaser1.Left = imgEnemy1.Left And imgLaser1.Left > imgEnemy1.Left + 855) Then
Score = Score + 1
End If
'If imgLaser1.Top = imgEnemy2.Top + 1000 Then
' Score = Score + 1
'End If
'If imgLaser1.Top = imgEnemy3.Top + 1000 Then
' Score = Score + 1
'End If
'If imgLaser1.Top = imgEnemy4.Top + 1000 Then
' Score = Score + 1
'End If
If reset = True Then
imgEnemy1.Left = 0
imgEnemy1.Top = 0
imgEnemy2.Left = 1920
imgEnemy2.Top = 0
imgEnemy3.Left = 3840
imgEnemy3.Top = 0
imgEnemy4.Left = 5400
imgEnemy4.Top = 0
End If
lblScore = Str(Score)
Wend
End Sub