Private Sub Form_KeyPress(KeyAscii As Integer)
Dim DelayLaser As Long
'S/s to move ship right
If (KeyAscii = 83 Or KeyAscii = 115) And imgChar.Left < 8880 Then
imgChar.Left = imgChar.Left + 400
'A/a moves ship left
ElseIf (KeyAscii = 65 Or KeyAscii = 97) And imgChar.Left > -150 Then
imgChar.Left = imgChar.Left - 400
'For the SpaceBar
ElseIf KeyAscii = 32 Then
imgLaser1.Top = imgChar.Top
imgLaser1.Left = imgChar.Left + 1120
imgLaser1.Top = imgChar.Top - 300
For DelayLaser = 1 To 100000000
imgLaser1.Top = imgLaser1.Top - 5
hold = DoEvents
Next DelayLaser
End If
End Sub
Private Sub mnuLEasy_Click()
' hMove and vMove record the number of steps
' through each section of the animation
Dim hMove As Integer
Dim vMove As Integer
Dim EnemyDelay As Long
' position the Enemy Object(s)
imgEnemy1.Top = 0
imgEnemy1.Left = 0
'Rate at which the the enemy will move horizontally
hMove = 5
'When Enemy Reaches at the edge it will add its own height and move down
vMove = 500
'Mode When everything has to start
continue = "yes"
'While Continue = "yes" things will start in the loop
While continue = "yes"
' 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 + hMove
'This will check if image is at the edge of the screen
If imgEnemy1.Left = 10000 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
hMove = hMove * -1
'Add height in twips, that way the image will move down
imgEnemy1.Top = imgEnemy1.Top + vMove
'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
hMove = hMove * -1
'Add height in twips, that way image will move down
imgEnemy1.Top = imgEnemy1.Top + vMove
End If
hold = DoEvents
Wend
End Sub