Computer Science Canada monopoly help >.> |
| Author: | JustTrying2GetBy [ Tue Jan 25, 2005 12:55 pm ] | ||
| Post subject: | monopoly help >.> | ||
i have gotten player one to make the first move successfully. now i am wondering how I would get player two to make his move....
I am wondering how to reset the values in my function so i can use new the dice again for player 2. Also, how would i be able to save the location of player one so player1 can make a 2nd move and continue from where he/she leftoff. |
|||
| Author: | ste_louis26 [ Tue Jan 25, 2005 1:06 pm ] |
| Post subject: | |
Sometimes simplier is better. You don't need functions when you could make it simplier by just using procedures |
|
| Author: | JustTrying2GetBy [ Tue Jan 25, 2005 1:16 pm ] |
| Post subject: | |
arent the two the same...basically? and could u help with my problem? sum1? edit: i was told that i needed the function to call on the data of the dice so i could use that information to move teh pieces.... |
|
| Author: | cycro1234 [ Tue Jan 25, 2005 1:17 pm ] |
| Post subject: | |
You could a global variable called "playerTurn" That controls then turns. Then make an if statement checking if playerTurn = 1 or 2 . |
|
| Author: | JustTrying2GetBy [ Tue Jan 25, 2005 1:31 pm ] |
| Post subject: | |
more detail please |
|
| Author: | Tony [ Tue Jan 25, 2005 2:35 pm ] | ||
| Post subject: | |||
you're not suppost to leave any data inside of a function. They are suppost to be clean. Value goes in, value goes out. Nothing gets left inside. as for the player flag, it's really simple. For 2 player game I like to use the following trick.
as you can see, each time though the loop the variable flips between 1 and -1, representing two different players. If you have more players, you can use a similar approach, where you increment the player ID by 1 each time untill you get to the last player. this way when a function affect the player, you just check your global variable to see which player is to be affected. |
|||
| Author: | basketball4ever [ Wed Jan 26, 2005 1:20 am ] | ||
| Post subject: | |||
|
|||
| Author: | Drakain Zeil [ Wed Jan 26, 2005 1:10 pm ] | ||||
| Post subject: | |||||
tony wrote: you're not suppost to leave any data inside of a function. They are suppost to be clean. Value goes in, value goes out. Nothing gets left inside.
I did somthing like that for a toggle option, but instead of integers, I used boolean. So it would be something like this...
as for the player flag, it's really simple. For 2 player game I like to use the following trick.
as you can see, each time though the loop the variable flips between 1 and -1, representing two different players. If you have more players, you can use a similar approach, where you increment the player ID by 1 each time untill you get to the last player. this way when a function affect the player, you just check your global variable to see which player is to be affected.
|
|||||