aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay Hogenson <rayhogenson@gmail.com>2012-04-11 15:44:38 -0800
committerRay Hogenson <rayhogenson@gmail.com>2012-04-11 15:44:38 -0800
commit86af258b3982d280d041b72eae09a90fdc8afdfa (patch)
treef960c2e10f072aad17f55d5033e4df31ed1a2db7
parent2d52dff5855235e060f4d5c2642cb1a938d1076b (diff)
downloadyetihack-86af258b3982d280d041b72eae09a90fdc8afdfa.tar.zst
added an intro
-rw-r--r--include/yeti.h4
-rw-r--r--os/windows/Makefile2
-rw-r--r--src/Makefile2
-rw-r--r--src/YetiHack.cpp121
4 files changed, 113 insertions, 16 deletions
diff --git a/include/yeti.h b/include/yeti.h
index 592e09f..50ecf4f 100644
--- a/include/yeti.h
+++ b/include/yeti.h
@@ -1,3 +1,7 @@
+#ifndef YETI_H
+#define YETI_H
+#endif
+
#include <vector>
using namespace std;
class yeti
diff --git a/os/windows/Makefile b/os/windows/Makefile
index e078d8e..b8985ed 100644
--- a/os/windows/Makefile
+++ b/os/windows/Makefile
@@ -1,5 +1,5 @@
yetihack.exe: src/YetiHack.cpp src/yeti.cpp
- i486-mingw32-g++ src/YetiHack.cpp src/yeti.cpp -o src/yetihack.exe -L os/windows/yetihack-windows/pdcurses.dll -static -lpdcurses -Iinclude -static-libgcc -static-libstdc++
+ i486-mingw32-g++ src/YetiHack.cpp src/yeti.cpp -o src/yetihack.exe -L os/windows/yetihack-windows/pdcurses.dll -static -lpdcurses -Iinclude -static-libgcc -static-libstdc++ -DWINDOWS
-rm os/windows/yetihack-windows/yetihack.exe
ln src/yetihack.exe os/windows/yetihack-windows/
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)
{