Guest User

Untitled

a guest
Oct 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. function simGroup::pt( %this )
  2. {
  3. // loop hell protection
  4. cancel( %this.pt );
  5.  
  6. // erase previous frame
  7. %this.erasePong();
  8. %this.eraseScore( 0 );
  9. %this.eraseScore( 1 );
  10. %this.erasePaddle( 0 );
  11. %this.erasePaddle( 1 );
  12.  
  13. // move AI paddles
  14. %this.movePaddle( 0 );
  15. %this.movePaddle( 1 );
  16.  
  17. // fix AI paddles
  18. for ( %i = 0 ; %i < 2 ; %i++ )
  19. {
  20. if ( %this.pd[ %i ] < 0 )
  21. {
  22. %this.pd[ %i ] = 0;
  23. }
  24.  
  25. if ( %this.pd[ %i ] >= %this.height - 7)
  26. {
  27. %this.pd[ %i ] = %this.height - 7;
  28. }
  29. }
  30.  
  31. // main pong code (well, not really "main")
  32. if ( !%this.movePong() )
  33. {
  34. return;
  35. }
  36.  
  37. // draw frame
  38. %this.drawPong();
  39. %this.drawPaddle( 0 );
  40. %this.drawPaddle( 1 );
  41. %this.drawScore( 0 );
  42. %this.drawScore( 1 );
  43.  
  44. // set up next frame
  45. %this.pt = %this.schedule( 1000 / 15, "pt" );
  46. }
Add Comment
Please, Sign In to add comment