Take a look at these lines from the code you posted:
There are a couple of things wrong here. First of all, notice how I formatted the code. I did this because a for loop only repeats the first line immediately afterwards. When I'm coding, I typically indent the line that is being repeated. I doubt this is what you intend. If you want the loop to repeat multiple lines,
you should use { } to surround them. In fact, it is a good practice to use { } even if you only want to repeat a single line of code. That way you can easily add more lines of code without breaking it.
However, there slightly easier way to do this. In particular, I see that i already counts from xStart to xEnd. If you do it right, you can use i in the loop to show you which element in the array to access. If you use a little ingenuity, you can also use i to give you the y coordinate in the array as well. As a hint, what if i starts at 0. What do you want to count up to (or down to) in the for loop? Also, is there a way to make the code "calculate" the direction to move rather than using an if statement? If it helps, think about what the slope of the line means? In other words, how do you calculate slope and how can you use that information?
I hope this helps give you some ideas. Good luck.
Layne