topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday May 18, 2025, 2:34 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SteveK21 [ switch to compact view ]

Pages: [1]
1
Developer's Corner / Help with Processing 1.0
« on: October 27, 2009, 10:39 AM »
I am working from this code and was wondering if anyone had any tips on how to get each book 2 drop down into a bin by using a key press...

Book myBook1;
Book myBook2;
Book myBook3;
Book myBook4;

void setup()
{
  size(300,300);
  myBook1 = new Book(color(255,0,0),120,200,1);
  myBook2 = new Book(color(0,0,255),80,200,1);
  myBook3 = new Book(color(0,255,0),40,200,1);
  myBook4 = new Book(color(100,100,100),0,200,1);
}

void draw()
{
  background(255);
  myBook1.move();
  myBook1.display();
  myBook2.move();
  myBook2.display();
  myBook3.move();
  myBook3.display();
  myBook4.move();
  myBook4.display();
  line(0, 204, 250, 204);
}

class Book
{
  color c;
  float xpos;
  float ypos;
  float xspeed;

  Book(color tempC, float tempXpos, float tempYpos, float tempXspeed)
  {
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    xspeed = tempXspeed;
  }

  void display()
  {
    stroke(0);
    fill(c);
    rectMode(CENTER);
    rect(xpos,ypos,35,5);
  }

  void move()
  {
    xpos = xpos + xspeed;
    if (xpos > width)
    {
      xpos = 0;
    }
  }
}

Pages: [1]