nickytenera09
YaBB Newbies
Offline
Posts: 8
Re: graphic things!
Reply #20 - Jul 4th , 2009, 5:11am
Shape myShape; Shape myShape2; Shape myShape3; Shape myShape4; Shape myShape5; String buffer = ""; void setup() { //myShape = new Shape(); //myShape2 = new Shape(); //myShape3 = new Shape(); //myShape4 = new Shape(); //myShape5 = new Shape(); background(255); size(200,200,P3D); frameRate (60); } void draw() { readBuffer(); if (myShape != null) { myShape.drawMe(); } if (myShape2 != null) { myShape2.drawMe2(); } if (myShape3 != null) { myShape3.drawMe3(); } if (myShape4 != null) { myShape4.drawMe4(); } if (myShape5 != null) { myShape5.drawMe5(); } } void readBuffer() { if(buffer.contains("rect") || buffer.contains("RECT")){ noStroke(); println("I JUST DREW A RECTANGLE! YAY!"); myShape = new Shape(); buffer = new String(); } if(buffer.contains("line") || buffer.contains("LINE")){ println("I JUST DREW A LINE! YAY!"); myShape2 = new Shape(); buffer = new String(); } if(buffer.contains("circle") || buffer.contains("CIRCLE")){ println("I JUST DREW A ELLIPSE! YAY!"); myShape3 = new Shape(); buffer = new String(); } if(buffer.contains("ellipse") || buffer.contains("ELLIPSE")){ println("I JUST DREW A ELLIPSE! YAY!"); myShape4 = new Shape(); buffer = new String(); } if(buffer.contains("cube") || buffer.contains("CUBE")){ println("I JUST DREW A CUBE! YAY!"); myShape5 = new Shape(); buffer = new String(); } if(buffer.contains("movedownr") || buffer.contains("MOVEDOWNR")){ background (255); if (myShape != null) { myShape.y += 10; buffer = new String(); } } if(buffer.contains("movedownl") || buffer.contains("MOVEDOWNL")){ background (255); if (myShape2 != null) { myShape2.y += 10; myShape2.h += 10; buffer = new String(); } } if(buffer.contains("movedownci") || buffer.contains("MOVEDOWNCI")){ background (255); if (myShape3 != null) { myShape3.y += 10; myShape3.h += 10; buffer = new String(); } } if(buffer.contains("movedowne") || buffer.contains("MOVEDOWNE")){ background (255); if (myShape4 != null) { myShape4.y += 10; myShape4.h += 10; buffer = new String(); } } if(buffer.contains("movedowncu") || buffer.contains("MOVEDOWNCU")){ background (255); if (myShape5 != null) { myShape5.y += 10; buffer = new String(); } } if(buffer.contains("moveupr") || buffer.contains("MOVEUPR")){ background (255); if (myShape != null) { myShape.y -= 10; buffer = new String(); } } if(buffer.contains("moveupl") || buffer.contains("MOVEUPL")){ background (255); if (myShape2 != null) { myShape2.y -= 10; myShape2.h -= 10; buffer = new String(); } } if(buffer.contains("moveupci") || buffer.contains("MOVEUPCI")){ background (255); if (myShape3 != null) { myShape3.y -= 10; myShape3.h -= 10; buffer = new String(); } } if(buffer.contains("moveupe") || buffer.contains("MOVEUPE")){ background (255); if (myShape4 != null) { myShape4.y -= 10; myShape4.h -= 10; buffer = new String(); } } if(buffer.contains("moveupcu") || buffer.contains("MOVEUPCU")){ background (255); if (myShape5 != null) { myShape5.y -= 10; buffer = new String(); } } } void keyPressed() { buffer += key; println(buffer); } class Shape { int a,b,c,d,diam,s,r; int w,h; float x,y; Shape() { a = (int)random(255); b = (int)random(255); c = (int)random(255); d = (int)random(255); s = (int)random(10); r = (int)random(90); diam = (int)random(100); w = 10 + (int)random(200); h = 10 + (int)random(200); x = random(200); y = random(200); } void drawMe() { noStroke(); fill(a,b,c,d); rect(x,y,w,h); } void drawMe2() { smooth(); strokeCap(ROUND); strokeWeight (s); stroke (a,b,c,d); line (x,y,w,h); } void drawMe3() { noStroke(); fill (a,b,c,d); ellipseMode (CENTER); ellipse (x,y,diam,diam); } void drawMe4() { noStroke(); fill (a,b,c,d); ellipseMode (CENTER); ellipse (x,y,w,h); } void drawMe5 () { noStroke(); lights(); fill (a,b,c); translate(x,y,0); rotateY(r); box(50,50,50); } } this is what i've done to have other movements and other shapes... i have the LAST question... it this moment i can draw all the cubes and other shapes that i want BUT when i type movedown or up ... just the last one cube or shape stay on the screen and moves... how can i have always all the other cubes or shapes that i drawn before behind??? if i write background it draws the background everytime it moves and i can see the movements but not the other shapes behind... if i don't write it i can see the other shapes that are not moving behind but the shape's moving leaves just a stripe of color and can't see the step down or up o or whatever... i hope i'm clear... so i can write cube, line, circle etc, 10 times but when i write movedownCU or movedownL etc just the last cube or line or circle stay on the screen and moves.. the other 9 disappear! thanks a lot again for the help... nicole