We need a method that will make the player plane appear. The plane should appear on the left side of the screen, facing upwards. Like the clouds, the plane will wrap around the screen once it moves over the screen edges.
1. Add a new method called
SpawnPlayer
to the classgame
.Method SpawnPlayer:Int ()
2. Store the reference to the player plane object inside its corresponding field.
player = eng.CreateImage(atlas,0,0,64,64,cw/4,ch/2)
3. Scale it down to a factor of
0.7
and set the speed of the plane to8
.player.SetScale(0.7) player.SetSpeed(8)
4. The player should wrap around the screen.
player.SetWrapScreen(True)
5. For collision detection, set the collision group to
grpPlayer
and the radius to24
pixels. As the plane is already scaled down, the actual radius will be stored as24
times0.7
.player.SetColGroup(grpPlayer) player.SetRadius(24)
6. Reset the
hit
points to0
. Then, close the method.hits=0 Return 0 End