diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/YetiHack.cpp | 121 |
2 files changed, 108 insertions, 15 deletions
diff --git a/src/Makefile b/src/Makefile index 4c36df5..25c741b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ yetihack: YetiHack.o yeti.o g++ -o yetihack YetiHack.o yeti.o -lncurses YetiHack.o: YetiHack.cpp - g++ -g -I../include -o YetiHack.o -c YetiHack.cpp + g++ -g -I../include -o YetiHack.o -c YetiHack.cpp -DLINUX yeti.o: yeti.cpp g++ -g -I../include -o yeti.o -c yeti.cpp diff --git a/src/YetiHack.cpp b/src/YetiHack.cpp index 6c887e4..1eb6f38 100644 --- a/src/YetiHack.cpp +++ b/src/YetiHack.cpp @@ -19,18 +19,22 @@ along with YetiHack. If not, see <http://www.gnu.org/licenses/>. #include <iostream> #include <curses.h> #include <cstdlib> -#include <time.h> +#include <ctime> #include <vector> #include <cstring> #include <fstream> #include <sstream> #include <cmath> +#ifdef LINUX + #include <unistd.h> +#endif +#ifdef WINDOWS + #include <windows.h> +#endif #include "yeti.h" -#define Linux using namespace std; void endCurses(); void startCurses(); -int wait(int); int start(bool, bool, double); void story(bool); bool smessage(int, string, bool); @@ -38,6 +42,7 @@ vector<int> turns(int); const char* convert(int); void menu(bool); void help(); +void intro(); void endCurses() { @@ -53,15 +58,6 @@ void startCurses() keypad(stdscr, true); } -int wait(int seconds) -{ - int snum; - int initial = time(NULL); - do - { - snum = time(NULL) - initial; - } while (snum < seconds); -} int start(bool immortal, bool story, double escapeturns) { int escapeturnsold = (int)escapeturns; @@ -215,7 +211,7 @@ int start(bool immortal, bool story, double escapeturns) erase(); if (playagain == 'y') { - #ifdef Windows + #ifdef WINDOWS system("cls"); #endif return 1; @@ -223,7 +219,7 @@ int start(bool immortal, bool story, double escapeturns) else { endCurses(); - #ifdef Windows + #ifdef WINDOWS system("cls"); #endif cout << "You survived " << count << " turns" << endl; @@ -432,6 +428,102 @@ void help() } while (input != '\n'); } +void intro() +{ + erase(); + int x, y; + getmaxyx(stdscr, y, x); + for (int xcoord = 0; xcoord < x; ++xcoord) + { + for (int ycoord = 0; ycoord < y; ++ycoord) + { + move(ycoord, xcoord); + addstr("."); + } + } + move(y / 2 - 1, 0); + addstr("@"); + move(y - 1,x - 1); + refresh(); + #ifdef LINUX + usleep(100000); + #endif + #ifdef WINDOWS + Sleep(100); + #endif + for (int i = 1; i < x / 2; ++i) + { + move(y / 2 - 1, i - 1); + addstr("."); + move(y / 2 - 1, i); + addstr("@"); + move(y - 1, x - 1); + refresh(); + #ifdef LINUX + usleep(100000); + #endif + #ifdef WINDOWS + Sleep(100); + #endif + } + move(y / 2 - 2, x / 2 - 1); + addstr("!"); + move(y - 1,x - 1); + refresh(); + #ifdef LINUX + usleep(200000); + #endif + #ifdef WINDOWS + Sleep(200); + #endif + move(y / 2 - 1, x - 1); + addstr("y"); + move(y - 1, x - 1); + refresh(); + #ifdef LINUX + usleep(100000); + #endif + #ifdef WINDOWS + Sleep(100); + #endif + move(y / 2 - 2, x / 2 - 1); + addstr("."); + for (int i = x - 1; i >= 0; --i) + { + if (i - (x / 2) + 1 >= 0) + { + move(y / 2 - 1, i - (x / 2) + 1); + } + else + { + move(y / 2 - 1, x + (i - (x / 2) + 1)); + } + addstr("."); + if (i - (x /2) >= 0) + { + move(y / 2 - 1, i - (x / 2)); + } + else + { + move(y / 2 - 1, x + (i - (x / 2))); + } + addstr("@"); + + move(y / 2 - 1, i + 1); + addstr("."); + move(y / 2 - 1, i); + addstr("y"); + move(y - 1, x - 1); + refresh(); + #ifdef LINUX + usleep(100000); + #endif + #ifdef WINDOWS + Sleep(100); + #endif + } +} + int main(int argc, char* argv[]) { /*startCurses(); @@ -442,6 +534,7 @@ int main(int argc, char* argv[]) addstr(convert(a)); }*/ startCurses(); + intro(); bool immortal = false; if (argc > 1 && strcmp(argv[1],"-c") == 0) { |
