# Generating stairs but it is eating into each other

#### maxlee09

my code is currently generating stairs based on the rounds, such as 16 in round 1, 32 in round 2 etc. so the problem is as the stairs go higher, the stairs start eating into each other's space. If possible, can anyone fix this problem? PS: I am using java swing. this is all generated on a jpanel.

int totalSteps = rdSteps;
int stairWidth = 5000;
int stairHeight = 50;
int width = 50;
int screenY = 0;
int currentStairY = stairHeight;
int currentStairX = getWidth() - 300;
int midp = getHeight() / 2;
for (int i = 0; i < currentStep; i++) {
currentStairY -= stairHeight - (stairHeight * i / totalSteps);
currentStairX -= width - (width * i / totalSteps);
}
int totalStairHeight = stairHeight * (currentStep * 2);

int panelMidpointY = getHeight(); // find midpoint of JPanel
// adjust position of stairs based on midpoint

int screenX = -currentStairX + (currentStep * 70);

// Draw stairs
int stairX = getWidth() - stairWidth + screenX;
int stairY = getHeight() - stairHeight + screenY;
for (int i = 0; i < rdSteps; i++) {
if (i <= currentStep && i%2 == 0) {
Color stairColor = Color.decode("0xA94035");
g2d.setColor(stairColor);
} else if(i <= currentStep && i%2 != 0) {
Color stairColor = Color.decode("0xF37B73");
g2d.setColor(stairColor);
}else{
g2d.setColor(stairColor);
}
g2d.fill(new Rectangle2D.Double(stairX, stairY, stairWidth - (100 * i), stairHeight));
double stairHeightDiff = (double) stairHeight / totalSteps;
stairY -= stairHeightDiff * (totalSteps - i);
}

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.