top of page

Our Recent Posts

Tags

No tags yet.

week 13: development

Working on fixing the timer from last lesson and trying to make objects disappear upon collision. Worked on randomising appearance of rubbish in arrays and found it difficult to make the rubbish all be different rather than the same piece repeated 6 times. Also started working on combining click and drag with the repeated images code. Started on the data collection, which needs a lot more work.

Completed most of the artwork, which will be inserted later after main code is done.

https://drive.google.com/open?id=1s6o0Ai3wHSxK9TNwxSBt8c2RRqkNbaWL

float bx; float by;

//!click and drag int boxSize = 30; boolean overBox = false; boolean locked = false; float xOffset = 0; float yOffset = 0;

//!randomised rubbish PImage[] rubbish = new PImage[6]; PImage img; float[] posX =new float [rubbish.length] ; float[] posY =new float [rubbish.length] ;

//!clocktimer int m; int count; float totalTime = 60; int currentTime = 60; float temp ;

//!datacollector int amount; boolean collected = false;

void setup(){ size(700,500); bx = width/2; by = height/2; rectMode(RADIUS); imageMode( CENTER); //! setting up for randomised rubbish imgs for (int i = 0; i < rubbish.length; i ++){ rubbish[i] = loadImage ("rubbish" + i + ".jpg"); image (rubbish[i], random(width), random(height), 50, 50); } for (int j = 0; j < rubbish.length;j ++){ posX[j] = random(width) ; posY[j] = random(200, 500); } int index = int(random(0, rubbish.length)); img = rubbish[index]; }

void draw(){ background(255); rect(600,250, 50,150);

//!click and drag if (mouseX > bx-boxSize && mouseX <bx + boxSize && mouseY > by-boxSize && mouseY <by + boxSize) { overBox = true; if(!locked) { fill(153); } } else { fill(153); overBox = false; } //!box disappears upon collision and is collected if (bx > (600) && bx < (650) && by > (250) && by < (400)){ // // dataCollector(1); // // need to msake it stsay collected = true; } else { //rect(bx, by, boxSize, boxSize); // } fill(0); rect(bx, by, boxSize, boxSize); } //dataCollector(); clocktimer(); }

void mousePressed() { if(overBox) { locked = true; } else { locked = false; } xOffset = mouseX-bx; yOffset = mouseY-by; }

void mouseDragged() { if(locked) { bx = mouseX - xOffset; by = mouseY - yOffset; } }

void mouseReleased() { locked = false; }

void clocktimer(){ // for (int i=0; i<36; i+=(1/6)){ // float angle = radians(i); // stroke(255,100,100); // arc(50,50,80,80,0,angle+PIE, PIE); //} count++; if(count >= 30){ currentTime--; count =0; println("ok"); } println(currentTime); println(totalTime); println(currentTime/totalTime); temp = (currentTime/totalTime); println(temp); fill(0); arc(50,50,80,80,0,(temp* TAU), PIE); } void dataCollector(){

fill(255, 0, 0); rect(600, 250, 50, 130-amount); if (collected){ amount = amount+1; } //rect(600, 250, 50, 130) }

bottom of page