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 — adding some data fields

  1. One of the elements of Pongo is the paddle, so we need to add fields to store its X and Y position at the beginning of the class definition. To add data fields we need to extend the pongo class.
    Class pongo Extends App
    Field pX:Float = 630.0 'X pos on the right side of the canvas
    Field pY:Float = 240.0 'Y pos in the middle of the canvas
    
  2. Next will be the data fields for the ball. X/Y position and its X/Y speed.
    Field pX:Float = 240.0 'Y pos in the middle of the canvas
    Field bX:Float = 320.0 'X pos of the ball in the middle of canvas
    Field bY:Float = 240.0 'Y pos in the middle of the canvas
    Field bdX:Float = 3.5 'X speed of the ball
    Field bdY:Float = 1.5 'Y speed of the ball
    
  3. For both enemy paddles, we need ...

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