getColor and counter function setup help
in
Programming Questions
•
11 months ago
Hi,
I am trying to set up a program that will increase the players score if the circle clicked on matches the "master" circles color and will rotate the color if the color doesn't match. I am thinking to use getColor for this however I am new to processing and am not sure how to start setting this up. Also I am trying to get a score counter going to keep track of the matches made. I was wondering if anyone may know of a good wat to execute this. My code so far is below. Thanks
- int c1 = (int)random(0, 4);
- int c2 = (int)random(0, 4);
- int c3 = (int)random(0, 4);
- int c4 = (int)random(0, 4);
- int c5 = (int)random(0, 4);
- int R[] = {
- 0, 224, 255, 35
- };
- int G[] = {
- 173, 0, 240, 31
- };
- int B[] = {
- 239, 139, 0, 32
- };
- color r1 = color(R[c1], G[c1], B[c1]);
- color r2 = color(R[c2], G[c2], B[c2]);
- color r3 = color(R[c3], G[c3], B[c3]);
- color r4 = color(R[c4], G[c4], B[c4]);
- color r5 = color(R[c5], G[c5], B[c5]);
- Circle crcl; //declare the object
- Score scr;
- Master mstr;
- void setup() {
- size(500, 500);
- crcl = new Circle(250, 350, 85);
- mstr = new Master(250, 200, 85);
- scr= new Score(250, 100);
- //crcl.diameter = 85;
- }
- void draw() {
- background(255);
- crcl.display();
- scr.display();
- mstr.display();
- /*
- //////////My ideas so far on how i want to go forward with the program///////
- scr.run();
- if (mousePressed == true) {
- Color = get(mouseX, mouseY);
- }
- if (Color == masterColor) {
- scr1++; // add one point to the score counter on top
- } else {
- r1++; // change the fill to the next random fill color. Also will need function to make to fill rotate back to r1 after r5 has been reached.
- }
- if (score > 30) {
- textSize(150);
- text("END", 250, 50);
- }
- }
- */
- }
- class Circle {
- float x, y, diameter;
- //float diameter;
- Circle(float xpos, float ypos, float dia ) {
- x = xpos;
- y = ypos;
- diameter = dia;
- }
- void display() {
- noStroke();
- fill(r1);
- ellipse(x, y, 85, 85);
- ellipse(x, y, 85, 85);
- }
- }
- class Master { //Circle w/ stroke == master circle
- float x, y, diameter;
- //float diameter;
- Master(float xpos, float ypos, float dia ) {
- x = xpos;
- y = ypos;
- diameter = dia;
- }
- void display() {
- strokeWeight(5);
- stroke(0);
- fill(r2);
- ellipse(x, y, 85, 85);
- ellipse(x, y, 85, 85);
- }
- }
- class Score {
- Score(float xpos, float ypos) {
- xpos = 250;
- ypos = 100;
- }
- void display() {
- noStroke();
- textAlign(CENTER);
- textSize(50); ///score placement test
- fill(237, 28, 36);
- text("0", 250, 100); ///score placement test
- }
- /*
- void run() {
- if (Color == masterColor1) {
- scr++;
- }
- */
- }
1