Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Building stairs with a loop JAVA

Name: Anonymous 2012-01-12 15:56

Hey, I'm trying to build these stairs made with rectangles. The user enters the number of stairs and half should be red, the other half should be blue. I've been stuck for two days. Can anyone give me some advice?
This is the example http://imgur.com/Qv9vu

Thanks!

Name: sage 2012-01-12 15:59

You're literally retarded

Name: Anonymous 2012-01-12 16:03

int maxStep = 10;
float x = 50;//initial pos
float y = 50;
int i;
for(i=0; i<minStep/2; i++){
drawRect(red, x, y, 20, 10); //whatever you are using to draw rect. assuming dimensions are 20x10
x +=10;
y +=10;
}
for(; i<maxStep; i++){
drawRect(blue, x, y, 20, 10); //whatever you are using to draw rect. assuming dimensions are 20x10
x +=10;
y +=10;
}

Name: Anonymous 2012-01-12 16:03

Easiest thing ever much?

Name: Anonymous 2012-01-12 17:57

Thanks! and thanks Sage...

Name: Anonymous 2012-01-12 21:18

Quit programming and become an arts major. Now.

Don't change these.
Name: Email:
Entire Thread Thread List