Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include "token.h"
- int main()
- {
- int board[18]; // игровое поле 1x16, нулевой элемент - карта "Начало", семнадцатый - карта "Выход"
- int dice = 0; // кубик
- int i;
- for (i = 0; i < 18; i++)
- {
- board[i] = i;
- }
- token player1;
- create(&player1, board[0]);
- printf("Текущее положение - %d\n", player1.currentPosition);
- printf("Бросить кубик? [y/n]\n");
- char action;
- while (action != 'n')
- {
- scanf("%c", &action);
- if (player1.currentPosition < 17)
- {
- switch (action)
- {
- case 'y': // генерируем случайное число для кубика
- srand(time(NULL));
- dice = rand() % 6 + 1;
- printf("Бросаю кубик...\nВыпало значение %d\n", dice);
- move(&player1, dice);
- printf("Текущее положение - %d\n", player1.currentPosition);
- break;
- case 'n':
- printf("До свидания!\n");
- return 0;
- }
- }
- else
- {
- break;
- }
- }
- printf("Достигнут финиш\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement