Advertisement
_the_elf_

main.c

Oct 25th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include "token.h"
  5.  
  6. int main()
  7. {
  8.     int board[18]; // игровое поле 1x16, нулевой элемент - карта "Начало", семнадцатый - карта "Выход"
  9.     int dice = 0; // кубик
  10.     int i;
  11.     for (i = 0; i < 18; i++)
  12.     {
  13.         board[i] = i;
  14.     }
  15.     token player1;
  16.     create(&player1, board[0]);
  17.     printf("Текущее положение - %d\n", player1.currentPosition);
  18.     printf("Бросить кубик? [y/n]\n");
  19.     char action;
  20.     while (action != 'n')
  21.     {
  22.         scanf("%c", &action);
  23.         if (player1.currentPosition < 17)
  24.         {
  25.             switch (action)
  26.             {
  27.                 case 'y': // генерируем случайное число для кубика
  28.                     srand(time(NULL));
  29.                     dice = rand() % 6 + 1;
  30.                     printf("Бросаю кубик...\nВыпало значение %d\n", dice);
  31.                     move(&player1, dice);
  32.                     printf("Текущее положение - %d\n", player1.currentPosition);
  33.                     break;
  34.                 case 'n':
  35.                     printf("До свидания!\n");
  36.                     return 0;
  37.             }
  38.         }
  39.         else
  40.         {
  41.             break;
  42.         }
  43.     }
  44.     printf("Достигнут финиш\n");
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement