Advertisement
Guest User

Commandore 32 pong by mmdanggg2

a guest
Sep 16th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. //made by your friendly neighbourhood mmdanggg2
  2. playerX
  3. playerY
  4. playerHeight
  5. playerYBottom
  6.  
  7. ballX
  8. ballY
  9. ballXdir
  10. ballYdir
  11.  
  12. lives
  13. gameover
  14.  
  15. function updatePlayer:
  16. {
  17. changeY(playerY,1);
  18. playerYBottom = playerY - playerHeight;
  19. if(playerYBottom<0)
  20. {
  21. playerY++;
  22. playerYBottom = playerY - playerHeight;
  23. }
  24. if(playerY>31)
  25. {
  26. playerY--;
  27. playerYBottom = playerY - playerHeight;
  28. }
  29. }
  30.  
  31. function randomDir:
  32. negOne
  33. {
  34. negOne=-1;
  35. if(random)
  36. {
  37. return 1;
  38. }
  39. return negOne;
  40. }
  41.  
  42. function draw:
  43. {
  44. GPU.clear();
  45. GPU.fill(playerX,playerY,playerX,playerYBottom);
  46. GPU.plot(ballX,ballY);
  47. GPU.push();
  48. }
  49.  
  50. function updateBall:
  51. {
  52. ballX = ballX + ballXdir;
  53. ballY = ballY + ballYdir;
  54. if(ballX=0)
  55. {
  56. if(ballY<playerY)
  57. {
  58. if(ballY>playerYBottom)
  59. {
  60. ballX = 1;
  61. ballXdir = 1;
  62. return;
  63. }
  64. }
  65. if(lives=0)
  66. {
  67. gameover = 1;
  68. return;
  69. }
  70. draw();
  71. lives--;
  72. print(lives);
  73. ballX = 15;
  74. ballY = 15;
  75. ballXdir=randomDir();
  76. ballYdir=randomDir();
  77. return;
  78. }
  79. if(ballX>30)
  80. {
  81. ballXdir=-1;
  82. }
  83. if(ballY<1)
  84. {
  85. ballYdir = 1;
  86. }
  87. if(ballY>30)
  88. {
  89. ballYdir=-1;
  90. }
  91. }
  92.  
  93. function main:
  94. {
  95. gameover = 0;
  96. lives = 5;
  97.  
  98. playerX = 0;
  99. playerY = 17;
  100. playerHeight = 6;
  101. playerYBottom = playerY - playerHeight;
  102.  
  103. ballX = 15;
  104. ballY = 15;
  105. ballXdir=-1;
  106. ballYdir = 1;
  107. draw();
  108. print(lives);
  109. while(gameover = 0)
  110. {
  111. updatePlayer();
  112. updateBall();
  113. draw();
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement