DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Help with Processing 1.0  (Read 4,600 times)

SteveK21

  • Participant
  • Joined in 2009
  • *
  • Posts: 1
Help with Processing 1.0
« on: October 27, 2009, 03:39 PM »
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;
   }
 }
}
« Last Edit: October 27, 2009, 04:12 PM by SteveK21 »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Help with Processing 1.0
« Reply #1 on: October 28, 2009, 11:58 AM »
Hmm, that looks like school work, right?
What language is it? Oh, Processing 1.0. Didn't know such language existed :)

I can't see any Bin in that code, so I suppose you should start by making one. You could take the book as example, I think. The main difference would be that the Bin wouldn't have the move() function.

mahesh2k

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,426
    • Participated in NANY Challenge Twice
Re: Help with Processing 1.0
« Reply #2 on: November 03, 2009, 07:39 PM »
Maybe you need to ask this question in Discourse section of Processing.org

@jgpaiva, such language does exist. It's made to run on top of JVM,processing sketches run as applets.

Original address: https://www.donationcoder.com/forum/index.php?topic=20421.0