Loading...
Logo
Processing Forum
I posted a threadearlier to help me get started on this, and got some help. Now, I have made some headway. I can now get the "joystick" to snap back to the midpoint of the umbrella image. Now the tricky part is going to be getting the xVal and yVal to output "good" data through the serial port to the servos.
 
Furthermore, there will be a laser attached to the pan & tilt, which will point at an object on a wall. When it reaches said object, the program will display a different main image and a list image with selectable options for right and wrong answers.
 
Any advice would be helpful...
 
Here's what I have so far:
Copy code

  1. int ellipseSize = 70;
    int screenXSize = 1920;
    int screenYSize = 1080;
    int midUmbrellaX = 1750;
    int midUmbrellaY = 910;
    int xVal = 0;
    int yVal = 0;
    PImage umbrella; 
    PImage selection;
    PImage stars;
    PImage spectrum;
    PImage spectra;
    int value = 0;

  2. void setup() {
      size(screenXSize, screenYSize);
      frame.removeNotify();
      frame.setUndecorated(true);
      umbrella = loadImage("Umbrella_Corporation_logo.jpg");  // Load the image into the program 
      selection = loadImage("Grocery-List.jpg");
      stars = loadImage("absorptionspec.jpg");
      spectrum = loadImage("types_of_spectra.jpg");
      spectra = loadImage("spectra.jpg ");
    }
  3. void draw() {
      frame.setLocation(0, 0);
      noCursor();
      stroke(0);
      strokeWeight(40);
      line(0, 0, 1920, 0);
      line(0, 0, 0, 1080);
      line(1920, 0, 1920, 1080);
      line(0, 1080, 1920, 1080);
      image(umbrella, 1600, 760);
      image(selection, 1600, 20);
      image(stars, 20, 20); 
      fill(0, 64, 255, 127);
      float mx = constrain(mouseX, 1600 + (ellipseSize/2), 1900 - (ellipseSize/2));
      float my = constrain(mouseY, 760 + (ellipseSize/2), 1060 - (ellipseSize/2));
      smooth();
      ellipseMode(CENTER);
  4.   if (mousePressed) {
        if (mouseX < midUmbrellaX && mouseX >= 1600 && xVal > -1500) {
          xVal = xVal - 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("x= ");
          println(xVal);
        }
  5.     if (mouseX > midUmbrellaX && mouseX <= 1900 && xVal < 1500) {
          xVal = xVal + 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("x= ");
          println(xVal);
        }
  6.     if (mouseY < midUmbrellaY && mouseY >= 760 && yVal < 1500) {
          yVal = yVal + 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("y= ");
          println(yVal);
        }
       
        if (mouseY > midUmbrellaY && mouseY <= 1060 && yVal > -1500) {
          yVal = yVal - 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("y= ");
          println(yVal);
        }
      }
  7.   if (mousePressed == false) {
        strokeWeight(1);
        ellipse(midUmbrellaX, midUmbrellaY, ellipseSize, ellipseSize);
        xVal = 0;
        yVal = 0;
      }
      else if (mousePressed == true) {
        strokeWeight(1);
        ellipse(mx, my, ellipseSize, ellipseSize);
      }
     
      if (xVal >= 25 && xVal <= 100 && yVal >= 25 && yVal <= 100) {
        image(spectrum, 20, 20);
        image(spectra, 1600, 20);
      }
    }

Replies(2)

Ok... so I have made a little more progress, but now here comes the hard part. The spectrumList image is a picture showing the 7 spectrums for each class of star. I need to be able to point the pan & tilt laser at a star, and then prompt the user to match the spectrum that pops up with the spectrum on the list. Then information on the star will pop up if guessed correctly. Basically, I will be making 7 buttons on the spectrumList image, and checking to see if the right one is selected.
 
Here is my code so far:
Copy code

  1. int ellipseSize = 70;
    int screenXSize = 1920;
    int screenYSize = 1080;
    int midUmbrellaX = 1702;
    int midUmbrellaY = 867;
    int xVal = 0;
    int yVal = 0;
  2. //int spectrumHeight = 44;
    //int spectrumWidth = 333;
    //int OStarX = 1567;
    //int OStarY = 134;
  3. PImage umbrella; 
    PImage spectrumlist;
    PImage title;
    PImage spectrum;
    PImage oTypeSpec;
    PImage bTypeSpec;
    PImage aTypeSpec;
    PImage fTypeSpec;
    PImage gTypeSpec;
    PImage kTypeSpec;
    PImage mTypeSpec;
    PImage oTypeStar;
    PFont font; // Declare the variable
    int value = 0;

  4. void setup() {
  5.   size(screenXSize, screenYSize);
      frame.removeNotify();
      frame.setUndecorated(true);
      umbrella = loadImage("Umbrella_Corporation_logo.jpg");  // Load the image into the program 
      title = loadImage("title.JPG");
      spectrum = loadImage("types_of_spectra.jpg");
      oTypeSpec = loadImage("otypespectra.JPG");
      bTypeSpec = loadImage("btypespectra.JPG");
      aTypeSpec = loadImage("atypespectra.JPG");
      fTypeSpec = loadImage("ftypespectra.JPG");
      gTypeSpec = loadImage("gtypespectra.JPG");
      kTypeSpec = loadImage("ktypespectra.JPG");
      mTypeSpec = loadImage("mtypespectra.JPG");
      oTypeStar = loadImage("Type_O_star.jpg");
      spectrumlist = loadImage ("classificationspectra.jpg");
      font = loadFont("Ziggurat-32.vlw"); // Load the font
      background(0);
    }
  6. void draw() {
      frame.setLocation(0, 0);
      noCursor();
      stroke(50);
      strokeWeight(5);
      line(1505, 0, 1505, 1080);
      image(umbrella, 1552, 717);
      image(spectrumlist, 1505, 100);
      image(title, 0, 0);
      textFont(font, 28); // Set the current text font
      String s = "Phasellus a ante elit, in gravida neque. Fusce in lectus arcu, ut pellentesque leo. Ut eu lacus quis mi varius sodales. Duis porta lacinia nulla, quis convallis neque vehicula vel. Sed eget risus eu sem luctus vestibulum dignissim ultricies quam. Phasellus sagittis lectus a leo tempor commodo. Duis non ipsum risus, vitae molestie orci. In ipsum sapien, tempor vitae viverra in, posuere eget odio. Nam semper nulla nulla, sed rutrum erat. Donec varius dui vel justo malesuada ut sollicitudin ante commodo. Donec arcu elit, suscipit id accumsan ac, auctor et magna. Nam lobortis, nisi faucibus venenatis ultricies, lorem lectus semper felis, rutrum ultrices tellus nisl a nisi. Duis sed nibh risus. Vivamus facilisis laoreet augue, at molestie purus convallis mattis. Nunc vel quam ut massa molestie tristique in ut tortor. Ut facilisis gravida orci sit amet laoreet. Aliquam ac urna sed massa bibendum bibendum sit amet ac arcu. Pellentesque rutrum, urna ut pellentesque gravida, leo odio fringilla justo, sit amet aliquam mauris est eu tellus. Praesent nec ipsum vel lorem dictum congue nec non massa. Ut consectetur semper ornare. Praesent lorem sapien, sagittis eget volutpat id, iaculis tempor ligula. Integer at lacus suscipit sapien euismod dapibus nec eu quam. Vivamus.";
      text(s, 1080, 0, 420, 1080);

  7.   checkUmbrella();
  8.   if (xVal >= 25 && xVal <= 100 && yVal >= 25 && yVal <= 100)
      {
        image(oTypeStar, 0, 0);
        image(oTypeSpec, 1568, 29);
        //game function
      }
    }
  9. void checkUmbrella()
    {
      fill(0, 64, 255, 127);
      float mx = constrain(mouseX, 1552 + (ellipseSize/2), 1852 - (ellipseSize/2));
      float my = constrain(mouseY, 717 + (ellipseSize/2), 1017 - (ellipseSize/2));
      smooth();
      ellipseMode(CENTER);
  10.   if (mousePressed) {
        if (mouseX < midUmbrellaX && mouseX >= 1552 && xVal > -1500) {
          xVal = xVal - 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("x= ");
          println(xVal);
        }
  11.     if (mouseX > midUmbrellaX && mouseX <= 1852 && xVal < 1500) {
          xVal = xVal + 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("x= ");
          println(xVal);
        }

  12.     if (mouseY < midUmbrellaY && mouseY >= 717 && yVal < 1500) {
          yVal = yVal + 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("y= ");
          println(yVal);
        }
        if (mouseY > midUmbrellaY && mouseY <= 1017 && yVal > -1500) {
          yVal = yVal - 1;
          println(mouseX-midUmbrellaX);
          println(midUmbrellaY-mouseY);
          print("y= ");
          println(yVal);
        }
      }
  13.   if (mousePressed == false) {
        strokeWeight(1);
        ellipse(midUmbrellaX, midUmbrellaY, ellipseSize, ellipseSize);
      }
      else if (mousePressed == true) {
        strokeWeight(1);
        ellipse(mx, my, ellipseSize, ellipseSize);
      }
    }
The latin text is just lorem ipsum. It will be the area where the star info shows up. Initially I want there to be simple instructions on how to play the game, and then when the correct spectrum is selected, have information on that star clasification displayed there.
 
Any help would be appreciated. If you need more info, just ask and I'll try my best to explain.