Computer Science Canada Concentration Help |
Author: | Illusion [ Sat Jun 10, 2006 7:58 pm ] | ||
Post subject: | Concentration Help | ||
I know that the Rand.Int of tileLocation chooses any number between 80 and 480, but how do I get the tiles to only show at the locations of (80, 160, 240, 320, 400, 480)?
|
Author: | Cervantes [ Sat Jun 10, 2006 8:30 pm ] | ||||||||
Post subject: | |||||||||
If you want to pick a random element of your tileLocation array,
or better yet,
But why do you even need a tileLocation array? All you're trying to do is pick a random multiple of 80 between 80 and 480.
Also, your code has a syntax error on this line:
Rand.Int is a function, not a procedure, and it takes two arguments, not three. Rand.Int should be used in preference to the procedure, randint. |
Author: | Illusion [ Sat Jun 10, 2006 9:36 pm ] |
Post subject: | |
ooh, okay. Thanks. ![]() btw, how would i make the tiles not repeat itself more than 2 times, in other words, only showing 2 times on the grid? |
Author: | Delos [ Sat Jun 10, 2006 11:35 pm ] | ||||
Post subject: | |||||
I'd suggest creating a 'tile' type with as much information attributed to it as necassary, for instance:
Then have an initialize function:
Whenever you draw a tile from thence, add one to the drawCount; and of course have a stipulation in the draw proc to only draw when drawCount is less than 2...or something thereabouts. Disclaimer: None of this code is tested, so it might be missing a few brackets or something ^^;. I don't know if the format I set up is in any way reflective of your own programming needs - so don't feel constrained by it. Simply understand the concepts of using types and initialization functions, in conjunction with arrays. From there, it's up to you to add the details. In short - this was just a brief example. |