A little help plz?
Author |
Message |
Jickman
|
Posted: Mon May 14, 2007 5:11 pm Post subject: A little help plz? |
|
|
hi, i've made a program with my brother on board games, and theres a problem, we don't know how to use 2 dice and also to make the figure go on the block, do i need to declare the block as a variable, can u gimme a lil help? a small example would be the best!
plz thank u |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Mon May 14, 2007 5:54 pm Post subject: RE:A little help plz? |
|
|
I'm not too sure what you mean. What exactly is a 'block' and how are you trying to use two dice? If you could show us what your code looks like currently, people may be able to give you a bit more help and direction with your problem. As it stands, your motives are quite foggy. |
|
|
|
|
![](images/spacer.gif) |
Jickman
|
Posted: Mon May 14, 2007 10:36 pm Post subject: RE:A little help plz? |
|
|
ok hmm what i mean is that u now in board games for example monopoly, to have a blocks such as illinois avenue, etc rite? u get what i mean? and i want to know if u roll 2 numbers and u use those 2 numbers to move on the total. THe figure is to idicate ur little object to represent u in the game. |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon May 14, 2007 11:01 pm Post subject: RE:A little help plz? |
|
|
If you're doing monopoly, you should probably have a one dimensional array (from 0 up to n-1, where n is the number of "blocks") of "blocks", as you call them.
Each player will have a number associated with them that represents the number of the block they are on.
When you roll the two dice (using Rand.Int), add the result to the player's position number, mod n.
code: |
player_position := (player_position + sum_of_dice) mod number_of_blocks
|
The mod serves to move the player back to the first tile after he's moved all the way around the board.
Check out the Turing Walkthrough if you're not familiar with arrays or records. |
|
|
|
|
![](images/spacer.gif) |
|
|