Let's say I have a list of 100 questions in my database. I also have an array of shuffled questions with a index size of 0-99 which I use to reference to the database. It's so I don't shuffled the database.
My question is that the game starts at question 0 (10 for 2nd round, 20 for 3rd etc). I tried using a x mod 10 but I have it ordered so I check whether or not the question I'm up to has exceeded the limi开发者_开发知识库t for the round. (This stops the 11th question displaying on the screen) But since the game starts at question 0, the mod result is 0 and that would mean the end of the round. I need it to run question 0-9 stop at 10. next round 10-19 stop at 20.. etc
I don't want to have to hardcode it like: run question except if question number is 0, 10, 20... 80, 90 100. in one big if statement.
Any help would be great.
What about (x + 1) mod 10? If you offset by one you don't get 0 as a valid case.
精彩评论