|
| 1 | +var S1 = createSprite(100,100); |
| 2 | +S1.setAnimation("S1") |
| 3 | +var BK1 = createSprite(100,100); |
| 4 | +BK1.setAnimation("BK"); |
| 5 | +BK1.scale = 10 |
| 6 | +var score = 0; |
| 7 | +var GG = createSprite(200,400); |
| 8 | +GG.scale = 3; |
| 9 | +GG.setAnimation("Goal"); |
| 10 | +var RS1 = createSprite(5, 200); |
| 11 | +RS1.setAnimation ("RS"); |
| 12 | +var LS1 = createSprite(395, 200); |
| 13 | +LS1.setAnimation ("LS"); |
| 14 | +var TS1 = createSprite(190,5); |
| 15 | +TS1.setAnimation("TS"); |
| 16 | +var BLS1 = createSprite(55,400); |
| 17 | +BLS1.setAnimation("BLS"); |
| 18 | +var BRS1 = createSprite(358,430); |
| 19 | +BRS1.setAnimation("BRS"); |
| 20 | + |
| 21 | +//sprite creation |
| 22 | + |
| 23 | +BLS1.rotation = 28; |
| 24 | +BLS1.scale = 1.5; |
| 25 | +BRS1.rotation = -28; |
| 26 | +BRS1.scale = 1.5; |
| 27 | +var PA1= createSprite(200,380); |
| 28 | +PA1.setAnimation("P1") |
| 29 | +var TSR1 = createSprite(395,0); |
| 30 | +TSR1.setAnimation("TSR"); |
| 31 | +TSR1.rotation= 45; |
| 32 | +var TSL1 = createSprite (0,0); |
| 33 | +TSL1.setAnimation("TSL"); |
| 34 | +TSL1.rotation= 45; |
| 35 | +var POO= createSprite(200,110); |
| 36 | +POO.setAnimation("poo"); |
| 37 | +POO.scale=0.25; |
| 38 | + |
| 39 | +//sprite scale and rotation developer |
| 40 | + |
| 41 | +var ball = createSprite(200, 200); |
| 42 | +ball.setAnimation("golfball_1"); |
| 43 | +ball.scale = 0.06; |
| 44 | +var RP = createSprite(295,250); |
| 45 | +RP.setAnimation("triangle"); |
| 46 | +var RP2 = createSprite(100,250); |
| 47 | +RP2.setAnimation("triangle2"); |
| 48 | +ball.x = randomNumber(8, 388); |
| 49 | +ball.y = randomNumber(10, 340); |
| 50 | +ball.setVelocity(5, 10); |
| 51 | + |
| 52 | +//ball function maker ex.velocity |
| 53 | + |
| 54 | +createEdgeSprites(); |
| 55 | +function draw() { |
| 56 | + ball.bounceOff(edges); |
| 57 | + ball.bounceOff(RP); |
| 58 | + ball.bounceOff(RP2); |
| 59 | + ball.bounceOff(RS1); |
| 60 | + ball.bounceOff(TS1); |
| 61 | + ball.bounceOff(BLS1); |
| 62 | + ball.bounceOff(BRS1); |
| 63 | + ball.bounceOff(PA1); |
| 64 | + ball.bounceOff(TSR1); |
| 65 | + ball.bounceOff(TSL1); |
| 66 | + ball.bounceOff(POO); |
| 67 | + //ball bounce function |
| 68 | + if(keyDown("right")){ |
| 69 | + PA1.x = PA1.x + 3; |
| 70 | + } |
| 71 | + if (score==10){ |
| 72 | + ball.setVelocity(7,12) |
| 73 | + } |
| 74 | + if (score==25){ |
| 75 | + ball.setVelocity(10,16) |
| 76 | + } |
| 77 | + if (score==35){ |
| 78 | + ball.setVelocity(15,20) |
| 79 | + } |
| 80 | + if(keyDown("left")){ |
| 81 | + PA1.x = PA1.x - 3; |
| 82 | + } |
| 83 | + if(ball.isTouching(RP)|| ball.isTouching(RP2)){ |
| 84 | + score= score + 1; |
| 85 | + } |
| 86 | + if(ball.isTouching(POO)){ |
| 87 | + score= score + 2; |
| 88 | + } |
| 89 | + if (ball.isTouching(GG)){ |
| 90 | + var GG2Z = createSprite(650,550); |
| 91 | + GG2Z.setAnimation("GG2Z"); |
| 92 | + } |
| 93 | + if (score == 50) { |
| 94 | + var GG3 = createSprite(600,500); |
| 95 | + GG3.setAnimation("GG3") |
| 96 | + ball.setVelocity(0,0); |
| 97 | + } |
| 98 | + drawSprites(); |
| 99 | + stroke("red"); |
| 100 | + text("Score " + score, 50, 50); |
| 101 | +} |
| 102 | + |
| 103 | +//Paddle movement and world function creation |
0 commit comments