simonsays_cli.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <stdio.h>
  2. #include <assert.h>
  3. #include "simonsays_controller.h"
  4. #include "utilities.h"
  5. int main()
  6. {
  7. resetGame();
  8. printf("Loading game...\n");
  9. // TODO: LOADING SCREEN HERE
  10. preLoadGame();
  11. printf("Welcome to Simon Says!\nPress enter to start the game");
  12. // TODO: MAIN MENU HERE
  13. getchar();
  14. startGame();
  15. while (getCurrentGameState() == inGame)
  16. {
  17. printf("New Round!\n");
  18. currentGame.currentScore++;
  19. startNewRound();
  20. enum shape_names currentSimonMove = getCurrentSimonMove();
  21. printf("Simon Says.. Score(%d)\n", currentGame.currentScore - 1);
  22. for (int index = 0; index < currentGame.currentScore; index++)
  23. {
  24. // TODO: TIMED SEQUENCE HERE
  25. printf("%d\n", currentGame.simonMoves[index]);
  26. }
  27. printf("Your turn:\n");
  28. while (!isRoundComplete())
  29. {
  30. char userInput = getchar();
  31. if (userInput == '\n')
  32. continue; // getchar registers enter as an input..
  33. int playerAction = atoi(&userInput);
  34. onPlayerSelectedShapeCallback(playerAction);
  35. // TODO: INTERACT WITH USER INPUTS HERE
  36. if (getCurrentGameState() != inGame)
  37. {
  38. break;
  39. }
  40. }
  41. }
  42. if (getCurrentGameState() == gameOver)
  43. {
  44. // TODO: GAMEOVER SCREEN HERE
  45. printf("Game over!");
  46. }
  47. if (getCurrentGameState() == gameVictory)
  48. {
  49. // TODO: VICTORY SCREEN HERE
  50. printf("You've beat Simon!");
  51. }
  52. return 0;
  53. }