Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function simGroup::pt( %this )
- {
- // loop hell protection
- cancel( %this.pt );
- // erase previous frame
- %this.erasePong();
- %this.eraseScore( 0 );
- %this.eraseScore( 1 );
- %this.erasePaddle( 0 );
- %this.erasePaddle( 1 );
- // move AI paddles
- %this.movePaddle( 0 );
- %this.movePaddle( 1 );
- // fix AI paddles
- for ( %i = 0 ; %i < 2 ; %i++ )
- {
- if ( %this.pd[ %i ] < 0 )
- {
- %this.pd[ %i ] = 0;
- }
- if ( %this.pd[ %i ] >= %this.height - 7)
- {
- %this.pd[ %i ] = %this.height - 7;
- }
- }
- // main pong code (well, not really "main")
- if ( !%this.movePong() )
- {
- return;
- }
- // draw frame
- %this.drawPong();
- %this.drawPaddle( 0 );
- %this.drawPaddle( 1 );
- %this.drawScore( 0 );
- %this.drawScore( 1 );
- // set up next frame
- %this.pt = %this.schedule( 1000 / 15, "pt" );
- }
Add Comment
Please, Sign In to add comment