I asked some question before in this forum.
Now the game version is the new version with more items in it.
now, i have a 11 items to draw, '$'.
and i have a function in a header file called utils.h, GetRandom() function.
code:
Expand|Select|Wrap|Line Numbers
- inline unsigned GetRandom(unsigned min, unsigned max) {
- return rand() % (max - min + 1) + min;
- }
What my examiner said :
suppose you have decided to have 11 powerups. Where are youI have no idea what it means by min & max argument in GetRandom() function will depend on the size of the screen.
going to put them? So you'll neeed to use GetRandom at least 22 times to
get random x and y positions. The min and max will depend on the size of
the screen that you'll have.
So, what should i put in for the min & max argument? 11 and 25 (the height and width) ?
Please could someone show the example ? because i can't figure it out.
What i have tried (which is failed ) :
Expand|Select|Wrap|Line Numbers
- unsigned xPos;
- unsigned yPos;
- for(unsigned i = 0; i <= max; i++) {
- xPos = GetRandom(1, 275);
- yPos = GetRandom(1, 275);
- screen->Insert(xPos, yPos, '$'); // draw 11 of $ into screen
- }