Besides using a different image, which is placed and rotated differently, spawning the enemy plane works in a similar way to spawning the player plane.
1. Add a new method called
SpawnEnemy
to thegame
class.Method SpawnEnemy:Int ()
2. Assign the image of the plane to the corresponding
enemy
field.enemy = eng.CreateImage(atlas,64,0,64,64,cw/4*3,ch/2)
3. Scale it down to a factor of
0.7
.enemy.SetScale(0.7)
4. Set its angle to
180
degrees and give it a speed of8
.enemy.SetAngle(180) enemy.SetSpeed(8)
5. Let the enemy plane wrap around the screen edges.
enemy.SetWrapScreen(True)
6. For collision detection, set the collision group to
grpEnemy
and give it a radius of24
.enemy.SetColGroup(grpEnemy) enemy.SetRadius(24)
7. Reset its hit points to
0
and close the method.hitsC=0 canShoot=True Return 0 End