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;
}
}
}