Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. /*
  2. Tuto 7 : Score et bouton
  3. BOSSUET Léo
  4. 14/11/2017
  5. */
  6.  
  7. int x=12;
  8. int y=388;
  9. int vx=5;
  10. int dx=1;
  11. int vy=5;
  12. int dy=1;
  13. int xR=0;
  14. int yR=390;
  15. int score=0;
  16. int xB=820;
  17. int yB=280;
  18. int L=160;
  19. int H=70;
  20. int atemps=second();
  21. int ascore=0;
  22. boolean perdu=false;
  23.  
  24. void settings()
  25. {
  26. size(1000,400);
  27. }
  28.  
  29. void setup()
  30. {
  31.  
  32. }
  33.  
  34. void draw()
  35. {
  36. background(#08E0FA);
  37. stroke(0,0,0);
  38. strokeWeight(1);
  39. fill(#3AD80F);
  40. rect(800,0,200,400);
  41. textSize(35);
  42. fill(#050D9B);
  43. text("Snapi Pong",808,50);
  44. textSize(25);
  45. fill(#C90C2F);
  46. text("SCORE :",808,150);
  47. text(score,920,150);
  48. textSize(24);
  49. fill(#E8850C);
  50. text("Vx :",808,210);
  51. text(vx,860,210);
  52. textSize(24);
  53. fill(#E8850C);
  54. text("Vy :",808,240);
  55. text(vy,860,240);
  56. stroke(0,0,0);
  57. strokeWeight(5);
  58. fill(#F50C0C);
  59. rect(xB,yB,L,H);
  60. textSize(32);
  61. fill(#FC8B00);
  62. text("REJOUER",835,327);
  63. if(perdu==false)
  64. {
  65. stroke(0,0,0);
  66. strokeWeight(2);
  67. fill(#CE1515);
  68. ellipse(x,y,20,20);
  69. x=x+dx*vx;
  70. y=y+vy*dy;
  71. score=millis()/100-ascore;
  72. }
  73. stroke(0,0,0);
  74. strokeWeight(1);
  75. fill(#6BFA08);
  76. rect(xR,yR,10,80);
  77. yR=mouseY;
  78. if (second()-atemps==10)
  79. {
  80. vx=vx+2;
  81. vy=vy+2;
  82. atemps=second();
  83. }
  84. if (mouseY>320)
  85. {
  86. yR=320;
  87. }
  88.  
  89. if(x>=790)
  90. {
  91. dx=-1;
  92. }
  93. if(y>=390)
  94. {
  95. dy=-1;
  96. }
  97. y=y+vy*dy;
  98. if(y<=10)
  99. {
  100. dy=1;
  101. }
  102. if(x<20&&(y<mouseY+80)&&(y>mouseY))
  103. {
  104. dx=1;
  105. }
  106. else if(x<0)
  107. {
  108. perdu=true;
  109. textSize(40);
  110. fill(#C60000);
  111. text("Vous avez perdu!!!",220,200);
  112. }
  113. }
  114. void mouseClicked()
  115. {
  116. if((mouseX>xB)&&(mouseX<xB+L)&&(mouseY>yB)&&(mouseY<yB+H)&&(perdu==true))
  117. {
  118. println("clic");
  119. perdu=false;
  120. vx=5;
  121. vy=5;
  122. x=12;
  123. y=388;
  124. dx=1;
  125. dy=1;
  126. score=0;
  127. ascore=millis()/100;
  128. atemps=millis()/100;
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement