
上QQ阅读APP看书,第一时间看更新
Time for action — drawing the ball and the paddles
The next thing we want to draw is the ball and the paddles. Follow the ensuing steps:
- For this, we will add a single
DrawCircle
command and someDrawRect
commands to theOnRender
method.Method OnRender:Int() Cls 'Clear the canvas each frame DrawPlayField() 'Draw the play field DrawRect(pX, pY-30, 5, 60) 'Draw the player paddle DrawRect(eX[0], eY[0]-30, 5, 60) 'Draw the enemy paddle #1 DrawRect(eX[1], eY[1]-30, 5, 60) 'Draw the enemy paddle #2 DrawCircle(bX, bY, 5) 'Draw the ball with a radius of 5 Return True
- Better "save" than sorry. So, you should save this script under a name of your choice and test it again.
- For the rest of the process, you can use the pre-built script
Pongo_04.Monkey
. Does your game look like this now?

- Visually, we are 99 percent done. What's missing is the printing of the game score and a message about the game state. We will get to this soon.
The next thing we will add is the movement of the paddles and the ball.