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 — rendering the game field

Which elements will be rendered in the game?

  • The player paddle
  • Enemy paddle #1
  • Enemy paddle #2
  • The ball
  • A wall at the top
  • A wall at the bottom
  • A middle line

The last three elements can be grouped together as a background. So let us do just that:

  1. Now, insert the drawing routines for the background graphics. Between the OnUpdate method and the OnRender method, create a new method called DrawPlayField.
    Method OnUpdate:Int()
    Return True
    End
    Method DrawPlayField:Int()
    'Draw the top wall with a rectangle
    DrawRect(0,0,640,5)
    'Botton wall
    DrawRect(0,475,640,5)
    'Middle line, 13 pieces, each 10 pixel long
    For Local i:= 5 To 465 Step 20
    DrawRect(318,i,4,10)
    Next
    Return True
    End
    Method OnRender:Int()
    
  2. We need to modify the ...

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