kaesebrotverkaufer
YaBB Newbies
Offline
Posts: 1
how to get vertex moved?
Feb 12th , 2009, 1:18pm
hey, I think it's quite simple but I don't get it. I want a shape to be moved like that: float xpos; float speed = 2; float diameter = 30; void setup () { size(320, 240); smooth (); xpos = width / 2; } void draw () { background (45); if (xpos> width - diameter / 2) { speed = speed * -1; } if (xpos < diameter / 2) { speed = speed * -1; } xpos = xpos + speed; ellipse (xpos, height / 2, diameter, diameter); } what I have done looks like that: color haut = color(250, 183, 130); color rot = color (242, 63, 92); color susi = color (218, 184, 92); float xpos = 0; float ypos = 0; float speed = 2; void setup () { size (1000, 750); background (0); smooth (); frameRate (7); xpos = width / 2; } void draw () { pushMatrix(); translate (0,0); if (xpos> width ) { speed = speed * -1; } if (xpos < width) { speed = speed * -1; } xpos = xpos + speed; //MONSTER1 koerper_1 (); zaehne_1 (); linkes_Auge_1 (); rechtes_Auge_1 (); mund_1 (); zaehne_1 (); popMatrix (); } void koerper_1 () { beginShape(); fill (susi); vertex(634, 278); bezierVertex (650, 299, 660, 350, 636, 496); bezierVertex (626, 480, 704, 479, 749, 452); bezierVertex (624, 404, 755, 419, 763, 408); bezierVertex (759, 404, 744, 418, 750, 433); bezierVertex (731, 454, 713, 465, 675, 473); bezierVertex (624, 468, 624, 431, 636, 496); bezierVertex (675, 565, 702, 613, 729, 625); bezierVertex (729, 628, 712, 630, 649, 598); bezierVertex (647, 618, 629, 621, 610, 626); bezierVertex (653, 683, 638, 680, 557, 614); bezierVertex (505, 549, 527, 512, 563, 451); bezierVertex (551, 481, 550, 482, 498, 458); bezierVertex (477, 443, 458, 414, 445, 397); bezierVertex (431, 386, 438, 422, 463, 462); bezierVertex (541, 493, 561, 372, 563, 315); bezierVertex ( 566, 275, 634, 278, 634, 278); endShape(); } void linkes_Auge_1 () { beginShape (); fill (255); vertex (580, 330); bezierVertex (582, 333, 582, 339, 580, 343); bezierVertex ( 574, 346, 570, 344, 569, 340 ); bezierVertex ( 569, 336, 575, 329 , 580, 330); endShape (); } void rechtes_Auge_1 (){ beginShape (); vertex (636, 318); bezierVertex (642, 327,639, 336, 633, 339) ; bezierVertex (633, 339, 625, 336, 624, 329); bezierVertex (628, 320, 632, 318, 636, 318); endShape (); } void mund_1 (){ fill (rot); beginShape (); vertex (581, 364); bezierVertex (607, 362,639, 359, 646, 367); bezierVertex ( 639, 370 , 621, 369,591, 375 ); bezierVertex (576, 374, 571, 369,574, 364 ); endShape (CLOSE); } void zaehne_1 () { beginShape (); vertex (571, 371); bezierVertex (577, 369, 583, 372, 587, 368); bezierVertex (690, 370, 595, 366, 599, 370); bezierVertex (602, 367, 605, 368, 608, 365); bezierVertex (612, 367, 617, 364, 619, 367); bezierVertex (623, 363, 625, 367, 630, 364); bezierVertex (636, 365, 640, 363, 647, 365); endShape (); } but nothing happens. can anybody out there help me?