topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Wednesday April 17, 2024, 11:41 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

Author Topic: Help with Processing 1.0  (Read 3153 times)

SteveK21

  • Participant
  • Joined in 2009
  • *
  • Posts: 1
    • View Profile
    • Donate to Member
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;
    }
  }
}
« Last Edit: October 27, 2009, 11:12 AM by SteveK21 »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Help with Processing 1.0
« Reply #1 on: October 28, 2009, 06: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
    • View Profile
    • Donate to Member
Re: Help with Processing 1.0
« Reply #2 on: November 03, 2009, 01: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.