O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — spawning the player plane

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 class game.
    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 to 8.
    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 to 24 pixels. As the plane ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required