• fullscreen
  • ICM_week5OOPsketch_oct17a.pde
  • //Zena Koo
    //Intro to Computational Media
    //Week 5 assignment: object oriented programming
    //ITP NYU
    Comet myComet1;
    Comet myComet2; 
    Comet myComet3; // three objects!
    void setup() {
      size(600, 600);
      myComet1 = new Comet(color(#FFD603), 0, 100, 3, 6); // Parameters and different shades of yellow
      myComet2 = new Comet(color(#FFF703), 0, 10, 2, 4);
      myComet3 = new Comet(color(#FCFF58), 0, 5, 1, 2);
    void draw() {
      background(#0D2A50); //midnight blue background color
    class Comet { // Even though there are multiple objects, we still only need one class. No matter how many cookies we make, only one cookie cutter is needed.Isn’t object-oriented programming swell?
      color c;
      float xpos ;
      float ypos ;
      float xspeed;
     float yspeed;
      Comet(color tempC, float tempXpos, float tempYpos, float tempXspeed, float tempYspeed) { // The Constructor is defined with arguments.
        c = tempC;
        xpos = tempXpos;
        ypos = tempYpos;
        xspeed = tempXspeed;
        yspeed = tempYspeed;
      void display() {
        ellipse(xpos, ypos, 75, 75);
      void move() {
        xpos = xpos + xspeed;
        if (xpos > width) {
          xpos = 0;
        else {


    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.



    Report Sketch

    Report for inappropriate content

    Please provide details if possible:

    Your have successfully reported the sketch. Thank you very much for helping to keep OpenProcessing clean and tidy :)

    Make a Copyright Infringement claim

    Zena Koo

    OOP, sort of a comet?

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    I got a good amount of help from the Shiffman Processing book's 8-2 example on OOP in chapter 8. It was the only way I could understand how to develop code around this concept of object oriented programming. Even now, though, I think a lot of people in my class understand this much better than I do. Anyway, it turned out more like the view of oncoming traffic headlights at night. I think it looks pretty cool, though, for a first attempt.

    You need to login/register to comment.