user2231327
user2231327

Reputation: 13

For loop not running for my game in java

for(x = mapEdge.getMinX() ; x < mapEdge.getMaxX(); x += 11){        
            if(once){
                yLoop = mapEdge.getMinY() - yLoop;
            }
            for(y = yLoop ; y == yLoop - 11; y -= 11){
                g.drawImage(grass, x, y);
            }
            yLoop = y;
            once = true;
    }

for(y = yLoop ; y == yLoop - 11  ; y -= 11){
    g.drawImage(grass, x, y);

}

This loop is not running at all in my code; it just completely bypasses without doing anything.

Upvotes: 0

Views: 42

Answers (1)

rgettman
rgettman

Reputation: 178263

You initialize y to yLoop, but the condition is y == yLoop - 11, which is clearly false the first time, so the loop never runs.

I suspect you want a condition something like this:

for(y = yLoop ; y > yLoop - 11  ; y -= 11)

Upvotes: 2

Related Questions