Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. //quinn lincoln
  2.  
  3. import ddf.minim.*;
  4. import ddf.minim.signals.*;
  5. import ddf.minim.analysis.*;
  6. import ddf.minim.effects.*;
  7.  
  8. Minim minim;
  9. AudioSample collision;
  10. AudioSample begin;
  11. AudioSample GOAL;
  12. AudioSample music;
  13. Blox player;
  14. Blox blox;
  15. Blox player2;
  16. Bx bx1;
  17. Bx bx2;
  18. Bx bx3;
  19. PFont f;
  20. float N = 0;
  21.  
  22.  
  23. void setup(){
  24. smooth();
  25. size (1000,800);
  26. fill (255,0,255);
  27. f = loadFont ("ArialMT-48.vlw");
  28. blox = new Blox(3*width/4, height/2, 0, 0);
  29. fill (255,0,0);
  30. player = new Blox(width/2,height,1,1);
  31. player2 = new Blox (width/2,height/2,1,1);
  32. bx1 = new Bx (0,500);
  33. bx2 = new Bx (400,500);
  34. bx3 = new Bx (800,500);
  35. minim = new Minim(this);
  36. collision = minim.loadSample ("collision4.wav");
  37. begin = minim.loadSample ("start.wav");
  38. GOAL = minim.loadSample ("GOAL.wav");
  39. //music = minim.loadSample ("dazed and confused.wav");
  40. begin.trigger ();
  41. //music.trigger ();
  42. }
  43.  
  44. void draw() {
  45. blox.update();
  46. player.x = mouseX;
  47. player.y = mouseY;
  48.  
  49.  
  50.  
  51. OCD(); //colliion detection
  52.  
  53. background(0);
  54. if ((blox.x < (2.5*width/8 + 3*width/8)) && (blox.x > 2.5*width/8) && (blox.y > (15*height/16))){
  55. N = N + 1;
  56. }
  57. textFont(f,16);
  58. fill(255);
  59. text(N,500,300);
  60.  
  61. fill(0,0,120);
  62. bx1.draw();
  63. bx2.draw();
  64. bx3.draw();
  65. fill(255);
  66. rect(2.5*height/8, (15*width)/16, 3*width/8, height/16);
  67. fill (255);
  68. rect(2.5*width/8, 0, 3*width/8, height/16);
  69. fill(255,0,255);
  70. blox.draw();
  71. fill(0,177,0);
  72. player.draw();
  73. }
  74.  
  75. void OCD() {
  76. float speedx;
  77. speedx = ((abs(mouseX-pmouseX) + 1)/5);
  78. float speedy;
  79. speedy = ((abs(mouseY-pmouseY) + 1)/5);
  80. if (blox.velx > 200) {
  81. blox.velx *= 1/2;
  82. blox.vely *= 1/2;
  83. }
  84. if (blox.vely > 200) {
  85. blox.vely *= 1/2;
  86. blox.velx *= 1/2;
  87. }
  88. float d;
  89. d = sqrt(((blox.x - mouseX)*(blox.x-mouseX)) + ((blox.y - mouseY)*(blox.y - mouseY)));
  90. float z;
  91. z = 1;
  92. float q;
  93. q = 1;
  94. if (mouseX < blox.x) {
  95. z = -1;
  96. }
  97. if (mouseY < blox.y) {
  98. q = -1;
  99. }
  100. if ((d < blox.r)) {
  101. blox.velx = z*(speedx)*blox.velx;
  102. blox.vely = q*(speedy)*blox.vely;
  103. collision.trigger();
  104. }
  105. /*if (d == blox.r) {
  106. blox.velx = -1*(speedx)*blox.velx + 5*z;
  107. blox.vely = -1*(speedy)*blox.vely + 5*q;
  108. }*/
  109. }
Add Comment
Please, Sign In to add comment