code help?

Hello.  I am trying to make a game where the user arranges these objects before they disappear off the screen.  (Right now the face is Mickey Mouse.)  Does anyone have any suggestions for making the objects move more freely and independently because right now they are all swiveling around each other and it is impossible to make the face.

thank you..

Eli

float y = 0.0;
float x = -1;
void setup() {
size (600,600);
smooth();
fill(0);

}
void draw() {
background (255);
ellipse (50,y, 70,70);

float angle = map (mouseY, 1, width, 0, TWO_PI);
translate (5,3);
translate(mouseX, mouseY);
rotate (angle);
ellipse (50, 10, y, y);
ellipse (y, y, 50,50);
ellipse (0, y, y, y);
ellipse (y, y, 1, y);
ellipse(0,y,1,y);

translate(mouseY,mouseX);
translate(20,10);
fill(255,36,40);
ellipse(1, y, y, 30);

translate(mouseY,mouseX);
fill(255);
ellipse(50,50,60,60);
fill(0);
ellipse(50+10, 50, 30,30);

translate(mouseY,mouseX);
translate (1,3);
fill(255);
ellipse(50,50,60,60);
fill(0);
ellipse(50+10, 50,30, 30);

y += .2;
if (y > 500) {
y = – 1;

}

}

Advertisements

~ by eli on March 12, 2008.

2 Responses to “code help?”

  1. hello,

    I’m not really sure what you want to do? Are you saying you want it to be drag and drop arrangement? Maybe it would help if you break it down a bit, and describe it in a little more detail? This may help you break down and clarify each step? Sorry I can’t be more helpful, I’m just not to clear on what you are trying to do….

    Good luck,

  2. If I understand your problem rotating one object is causing the others to move too.

    If I understand what you are trying to do, the problem is that you have to translate, rotate, draw what you want, then translate back.

    Eg

    translate(x, y);
    // draws string s at position x,y at angle angDeg
    // Angle is in degrees (not radians)
    rotate(PI * angDeg/180.0);

    // draw all the stuff you want rotate HERE

    translate(-x, -y);

    Hope this helps, although I’m not sure if I’m addressing your problem.

    Eitan

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: