Hi guys. I am making a game called Bejeweled, I thought I would start this by making an array with random numbers from 0 to 4 (for the 5 gems). I would then transfer this array and assign the gems to each of the numbers.
I would appreciate any ones take on why this program always returns the same values.
If anyone could help, that would be awesome. Also this is all I have so far, if you have any better ideas on how to start, this could be interesting also.
I don't have a great deal of experience with C++ but do have a little with other languages. Thanks guys.
Even when I replace rand()%5 with say... 1. The same numbers still appear. So it isn't to do with the rand function. It is to do with the implementation of the numbers into the array.
This still returns the same values. Also if I change the rand function to say 1... It still outputs the same values.
This seems highly illogical as this should make all the values in the array 1...
I have tried copy and pasting the code to another new C++ source file and build-run again but still the same values appear.
Also as a quick note, I have put square brackets around my code and I can't see a change in the post..
Thanks NwN. That looks clearer now.
I have got the whole array to fill with random numbers.
A quick question... If I define an array board[8][8], does that give me a range board[0][0] to board[7][7] or board[8][8].
I'm pretty sure it's [7][7] but just to be sure.
Thank you for all your help guys. I'm sure you will see me pop up over the next 11 weeks for my project.
If you guys ever need help with something non c++ related, i'm your man! haha
You are telling the compiler "board is an array of 8 integers".
But because arrays are zero indexed, meaning the first element is at position board[0], the last position of the element will always be max_amount-1, in your case, 8-1, board[7].