Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //made by your friendly neighbourhood mmdanggg2
- playerX
- playerY
- playerHeight
- playerYBottom
- ballX
- ballY
- ballXdir
- ballYdir
- lives
- gameover
- function updatePlayer:
- {
- changeY(playerY,1);
- playerYBottom = playerY - playerHeight;
- if(playerYBottom<0)
- {
- playerY++;
- playerYBottom = playerY - playerHeight;
- }
- if(playerY>31)
- {
- playerY--;
- playerYBottom = playerY - playerHeight;
- }
- }
- function randomDir:
- negOne
- {
- negOne=-1;
- if(random)
- {
- return 1;
- }
- return negOne;
- }
- function draw:
- {
- GPU.clear();
- GPU.fill(playerX,playerY,playerX,playerYBottom);
- GPU.plot(ballX,ballY);
- GPU.push();
- }
- function updateBall:
- {
- ballX = ballX + ballXdir;
- ballY = ballY + ballYdir;
- if(ballX=0)
- {
- if(ballY<playerY)
- {
- if(ballY>playerYBottom)
- {
- ballX = 1;
- ballXdir = 1;
- return;
- }
- }
- if(lives=0)
- {
- gameover = 1;
- return;
- }
- draw();
- lives--;
- print(lives);
- ballX = 15;
- ballY = 15;
- ballXdir=randomDir();
- ballYdir=randomDir();
- return;
- }
- if(ballX>30)
- {
- ballXdir=-1;
- }
- if(ballY<1)
- {
- ballYdir = 1;
- }
- if(ballY>30)
- {
- ballYdir=-1;
- }
- }
- function main:
- {
- gameover = 0;
- lives = 5;
- playerX = 0;
- playerY = 17;
- playerHeight = 6;
- playerYBottom = playerY - playerHeight;
- ballX = 15;
- ballY = 15;
- ballXdir=-1;
- ballYdir = 1;
- draw();
- print(lives);
- while(gameover = 0)
- {
- updatePlayer();
- updateBall();
- draw();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement