hi, i'm trying to code the horizon using the random object. but i can't get it to work. it only gives me a bunch of scattered lines within a certain range.
@successfulbuild hi, i should have posted this a while ago, but i received the answer i needed from someone in my class. i needed to just add whatever the random number was to the y value each time.
y = this.getHeight() - 50;
g.setColor(Color.BLUE);
successfulbuild 11 months ago
for(x = 0; x < this.getWidth(); x++)
{
g.setColor(Color.BLUE)
g.fillRect(x,y,1,1);
g.setColor(Color.BLACK);
g.fillRect(x, y+1, 1, this.getHeight());
y += rand.nextInt(5) - 2
}
successfulbuild 11 months ago
hi, i'm trying to code the horizon using the random object. but i can't get it to work. it only gives me a bunch of scattered lines within a certain range.
bingin15 1 year ago
@bingin15 post the variable initializations and then the for loop, at the end of the code, and let me know if it works.
successfulbuild 11 months ago
@successfulbuild hi, i should have posted this a while ago, but i received the answer i needed from someone in my class. i needed to just add whatever the random number was to the y value each time.
bingin15 11 months ago