Stargrasper, I did check array bounds. In the first one, I check that yCurrent >= 1, so that there's no errors from yCurrent-1. In the second, I have yCurrent >= 0 in the while conditions.
Why wouldn't you use a for loop with multiple conditions? There's nothing wrong with it, especially when you consider that the following code examples are equivalent:
for(init; cond; update) { code; }
init;
while(cond) { code; update; }
Alright. I'm an idiot that didn't pay close enough attention to your code. Moving along.
Like I said, the reason I don't use for loops with multiple conditions is that it's entirely a stylistic thing. I don't know why I was taught not to do that. We
were taught that it was possible but told not to do it. Yes I'm entirely aware of the equivalency. When I start off by saying it's a stylistic thing, please assume I know what I'm talking about and am doing it my way for a particular reason.
And I was taught not to use do loops. Why exactly did you have that as a do loop initially, anyway? A while loop is a check that stops the player from doing anything illegal to begin with and a do loop means the content will happen at least once, so you need to make sure it's a legal move first.
I'm not sure I understand your concerns about Do-While loops (I'm using Mego's #2 example right now, because it feels the most familiar). Obviously those four lines were not the whole code - because of the way it's nested in an if-else ladder, it will never reach that loop if it's operative condition isn't already true. I also set it up that way because I forgot there exists a While loop as opposed to Do-While loops.
As for ANDs and ORs, I just plain got confused, and thought OR meant it would kick out if any condition turned False. Which is obviously dumb.
Okay. So long as it's impossible to get to that code when with an illegal move. No offense, but all of my code tutoring has told me that when given a code excerpt unless you know enough about a person's skill to say otherwise, always assume the worst.
I don't use do loops often just because I was taught not to use them. I was taught that if there is a block of code that you need to execute at least once and potentially an indeterminate number of times, use a boolean to control the loop and ensure that it executes at least once. I was taught that there is no other circumstance where you would want to use a do loop instead of a while or for loop. In your case, that's not necessary; just putting the conditions in the while will work. I'm not saying your way is wrong. I'm saying it's contradictory to how I would handle things and was thus curious as to why you were electing to do it that way.
Everyone, I have stylistic things I do that I do specifically because I was taught them when I was taught to program or developed them as habits later on and as I'm teaching others, have found that people usually learn better coding practices in the end by doing these. I'd be happy to discuss them, though.