| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #include <iostream>
- #include <cstdlib>
- #include <ncurses.h>
- #include <chrono>
- #include <thread>
- #include <time.h>
- #include <cstring>
- #include "Horse.h"
- #include "Race.h"
- #define WIDTH 1
- #define HEIGHT 1
- using namespace std;
- int main()
- {
- Race race = Race();
- WINDOW *menu_win;
- int c;
- int startx = 0;
- int starty = 0;
- menu_win = newwin(HEIGHT, WIDTH, starty, startx);
- string cppstr = "";
- char *cstr = 0;
- initscr();
- clear();
- noecho();
- cbreak();
- keypad(menu_win, TRUE);
- curs_set(0);
- // refresh();
- attron(A_STANDOUT);
- mvprintw(0, 1, " Steve Corya's hrtui 1.0 ");
- mvprintw(5, 0, "^B");
- mvprintw(5, 20, "^D");
- mvprintw(5, 40, "^E");
- attroff(A_STANDOUT);
- mvprintw(5, 3, "begin race");
- mvprintw(5, 23, "delete tallys");
- mvprintw(5, 43, "exit");
- cppstr = race.raceToString();
- cstr = new char[cppstr.length() + 1];
- // strcpy(cstr, cppstr.c_str());
- // mvprintw(1, 0, cstr);
- refresh();
- while (1)
- {
- c = wgetch(menu_win);
- switch (c)
- {
- // case 2:
- // mvprintw(7, 0, " ");
- // // srand(time(NULL));
- // race = Race();
- // while(!race.isFinished()){
- // cppstr = race.raceToString();
- // cstr = new char[cppstr.length() + 1];
- // strcpy(cstr, cppstr.c_str());
- // mvprintw(1, 0, cstr);
- // race.step(); // all horses advance...
- // std::this_thread::sleep_for(std::chrono::milliseconds(85));
- // refresh();
- // }
- // race.logWinner();
- // mvprintw(race.getWinner(), 36, "Horse #%d is the winner!", race.getWinner());
- // refresh();
- // break;
- case 4:
- if(!remove("winners.log")){
- mvprintw(7, 0, "log file successfully deleted");
- }
- refresh();
- break;
- case 5:
- break;
- default:
- mvprintw(7, 0, "character entered is %d", c);
- break;
- }
- if(c == 5){
- break;
- }
- }
- clrtoeol();
- refresh();
- endwin();
- return 0;
- }
|