The Game of Life Board
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Edgardo Caban
il 18 Apr 2020
Modificato: Walter Roberson
il 19 Apr 2020
Main_path = 1:150
Player1_turn = 0;
Player2_turn = 0;
for k = 1:length(Main_path)
randi(10)
end
For a project im recreating The Game of Life in Matlab, To create the board I have decided to utilize arrays. The board will have a total of 150 spaces and in order to move forward the player must use a spinner which goes from 1-10. I also have to choose pre-determined spaces to symbolize the action and payday spaces therefore i want to do it every 6 spaces there will be a payday space (which will be green) the rest should be yellow spaces. For now i cant figure out how to make the player move the amount of spaces depending on the number it gets on the spinner. So for example the spinner rolled 5 so the player moves 5 spaces. Then rolls 7 then the player moves 7 spaces therfore the player's position is Main_path(12)
3 Commenti
Risposta accettata
Walter Roberson
il 19 Apr 2020
redpos = next_red_position(position); %function call
newposition = position + spinner_value;
go_again = false;
if newposition >= redpos
position = redpos;
go_again = true;
elseif newposition > last_position
do something if you have passed the end
else
position = newposition;
end
if position == last_position
do something when you reach the end
end
2 Commenti
Walter Roberson
il 19 Apr 2020
Modificato: Walter Roberson
il 19 Apr 2020
deck = {Career1, Career2, Career3, Career4, Career5, Career6, Career7, Career8, Career9, Career10, Career11, Career12};
card = deck{randi(length(deck))};
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Conway's Game of Life in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!