Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //quinn lincoln
- import ddf.minim.*;
- import ddf.minim.signals.*;
- import ddf.minim.analysis.*;
- import ddf.minim.effects.*;
- Minim minim;
- AudioSample collision;
- AudioSample begin;
- AudioSample GOAL;
- AudioSample music;
- Blox player;
- Blox blox;
- Blox player2;
- Bx bx1;
- Bx bx2;
- Bx bx3;
- PFont f;
- float N = 0;
- void setup(){
- smooth();
- size (1000,800);
- fill (255,0,255);
- f = loadFont ("ArialMT-48.vlw");
- blox = new Blox(3*width/4, height/2, 0, 0);
- fill (255,0,0);
- player = new Blox(width/2,height,1,1);
- player2 = new Blox (width/2,height/2,1,1);
- bx1 = new Bx (0,500);
- bx2 = new Bx (400,500);
- bx3 = new Bx (800,500);
- minim = new Minim(this);
- collision = minim.loadSample ("collision4.wav");
- begin = minim.loadSample ("start.wav");
- GOAL = minim.loadSample ("GOAL.wav");
- //music = minim.loadSample ("dazed and confused.wav");
- begin.trigger ();
- //music.trigger ();
- }
- void draw() {
- blox.update();
- player.x = mouseX;
- player.y = mouseY;
- OCD(); //colliion detection
- background(0);
- if ((blox.x < (2.5*width/8 + 3*width/8)) && (blox.x > 2.5*width/8) && (blox.y > (15*height/16))){
- N = N + 1;
- }
- textFont(f,16);
- fill(255);
- text(N,500,300);
- fill(0,0,120);
- bx1.draw();
- bx2.draw();
- bx3.draw();
- fill(255);
- rect(2.5*height/8, (15*width)/16, 3*width/8, height/16);
- fill (255);
- rect(2.5*width/8, 0, 3*width/8, height/16);
- fill(255,0,255);
- blox.draw();
- fill(0,177,0);
- player.draw();
- }
- void OCD() {
- float speedx;
- speedx = ((abs(mouseX-pmouseX) + 1)/5);
- float speedy;
- speedy = ((abs(mouseY-pmouseY) + 1)/5);
- if (blox.velx > 200) {
- blox.velx *= 1/2;
- blox.vely *= 1/2;
- }
- if (blox.vely > 200) {
- blox.vely *= 1/2;
- blox.velx *= 1/2;
- }
- float d;
- d = sqrt(((blox.x - mouseX)*(blox.x-mouseX)) + ((blox.y - mouseY)*(blox.y - mouseY)));
- float z;
- z = 1;
- float q;
- q = 1;
- if (mouseX < blox.x) {
- z = -1;
- }
- if (mouseY < blox.y) {
- q = -1;
- }
- if ((d < blox.r)) {
- blox.velx = z*(speedx)*blox.velx;
- blox.vely = q*(speedy)*blox.vely;
- collision.trigger();
- }
- /*if (d == blox.r) {
- blox.velx = -1*(speedx)*blox.velx + 5*z;
- blox.vely = -1*(speedy)*blox.vely + 5*q;
- }*/
- }
Add Comment
Please, Sign In to add comment