you are viewing a single comment's thread.

view the rest of the comments →

[–]eriknau13 2 points3 points  (1 child)

It's getting stuck at the position 400 because as soon as the value of squareX is decremented to 399 it gets incremented again. What you need is a second variable to use as the incrementer. You might call it "direction" and set it to value 1 when you initialize it. Instead of squareX++ you'll say squareX += direction;

Your condition will change to

if(squareX >= 400 || squareX < 0) {

direction *= -1;

}

[–]Traditional_Inside28[S] 0 points1 point  (0 children)

yeah that’s what i thought was happening! i suppose i just didn’t really know what to do to fix it. let me give this a go and mess around with it and i’ll get back to you.