1
0

Main.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ncurses.h>
  4. #include <chrono>
  5. #include <thread>
  6. #include <time.h>
  7. #include <cstring>
  8. #include "Horse.h"
  9. #include "Race.h"
  10. #define WIDTH 1
  11. #define HEIGHT 1
  12. using namespace std;
  13. int main()
  14. {
  15. Race race = Race();
  16. WINDOW *menu_win;
  17. int c;
  18. int startx = 0;
  19. int starty = 0;
  20. menu_win = newwin(HEIGHT, WIDTH, starty, startx);
  21. string cppstr = "";
  22. char *cstr = 0;
  23. initscr();
  24. clear();
  25. noecho();
  26. cbreak();
  27. keypad(menu_win, TRUE);
  28. curs_set(0);
  29. // refresh();
  30. attron(A_STANDOUT);
  31. mvprintw(0, 1, " Steve Corya's hrtui 1.0 ");
  32. mvprintw(5, 0, "^B");
  33. mvprintw(5, 20, "^D");
  34. mvprintw(5, 40, "^E");
  35. attroff(A_STANDOUT);
  36. mvprintw(5, 3, "begin race");
  37. mvprintw(5, 23, "delete tallys");
  38. mvprintw(5, 43, "exit");
  39. cppstr = race.raceToString();
  40. cstr = new char[cppstr.length() + 1];
  41. // strcpy(cstr, cppstr.c_str());
  42. // mvprintw(1, 0, cstr);
  43. refresh();
  44. while (1)
  45. {
  46. c = wgetch(menu_win);
  47. switch (c)
  48. {
  49. // case 2:
  50. // mvprintw(7, 0, " ");
  51. // // srand(time(NULL));
  52. // race = Race();
  53. // while(!race.isFinished()){
  54. // cppstr = race.raceToString();
  55. // cstr = new char[cppstr.length() + 1];
  56. // strcpy(cstr, cppstr.c_str());
  57. // mvprintw(1, 0, cstr);
  58. // race.step(); // all horses advance...
  59. // std::this_thread::sleep_for(std::chrono::milliseconds(85));
  60. // refresh();
  61. // }
  62. // race.logWinner();
  63. // mvprintw(race.getWinner(), 36, "Horse #%d is the winner!", race.getWinner());
  64. // refresh();
  65. // break;
  66. case 4:
  67. if(!remove("winners.log")){
  68. mvprintw(7, 0, "log file successfully deleted");
  69. }
  70. refresh();
  71. break;
  72. case 5:
  73. break;
  74. default:
  75. mvprintw(7, 0, "character entered is %d", c);
  76. break;
  77. }
  78. if(c == 5){
  79. break;
  80. }
  81. }
  82. clrtoeol();
  83. refresh();
  84. endwin();
  85. return 0;
  86. }