aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/yeti.h2
-rw-r--r--src/YetiHack.cpp151
-rw-r--r--src/yeti.cpp10
3 files changed, 132 insertions, 31 deletions
diff --git a/include/yeti.h b/include/yeti.h
index 50ecf4f..093b69e 100644
--- a/include/yeti.h
+++ b/include/yeti.h
@@ -15,6 +15,8 @@ class yeti
void movetowards(int, int, vector<yeti>, int);
int xpos();
int ypos();
+ int setx(int);
+ int sety(int);
private:
int x;
int y;
diff --git a/src/YetiHack.cpp b/src/YetiHack.cpp
index fceeee0..4c02789 100644
--- a/src/YetiHack.cpp
+++ b/src/YetiHack.cpp
@@ -33,6 +33,7 @@ along with YetiHack. If not, see <http://www.gnu.org/licenses/>.
#endif
#include "yeti.h"
using namespace std;
+void osleep(int);
void endCurses();
void startCurses();
int start(bool, bool, double);
@@ -42,8 +43,19 @@ vector<int> turns(int);
const char* convert(int);
void menu(bool);
void help();
+//void demo();
void intro();
+void osleep(int miliseconds)
+{
+ #ifdef WINDOWS
+ Sleep(miliseconds);
+ #endif
+ #ifdef LINUX
+ usleep(miliseconds * 1000);
+ #endif
+}
+
void endCurses()
{
if (!isendwin())
@@ -347,8 +359,7 @@ void menu(bool immortal)
addstr("\t1. Arcade mode (classic)\n");
addstr("\t2. Story mode\n");
addstr("\t3. Help\n");
- addstr("\t4. Demo\n");
- addstr("\t5. Exit\n");
+ addstr("\t4. Exit\n");
addstr("Select an option to proceed: ");
refresh();
echo();
@@ -401,9 +412,6 @@ void menu(bool immortal)
help();
break;
case '4':
- intro();
- break;
- case '5':
endCurses();
exit(0);
break;
@@ -432,7 +440,8 @@ void help()
} while (input != '\n');
}
-void intro()
+// stupidest thing ever. Kept to make the file bigger.
+/*void demo()
{
erase();
int x, y;
@@ -449,12 +458,7 @@ void intro()
addstr("@");
move(y - 1,x - 1);
refresh();
- #ifdef LINUX
- usleep(100000);
- #endif
- #ifdef WINDOWS
- Sleep(100);
- #endif
+ osleep(100);
for (int i = 1; i < x / 2; ++i)
{
move(y / 2 - 1, i - 1);
@@ -474,22 +478,12 @@ void intro()
addstr("!");
move(y - 1,x - 1);
refresh();
- #ifdef LINUX
- usleep(200000);
- #endif
- #ifdef WINDOWS
- Sleep(200);
- #endif
+ osleep(200);
move(y / 2 - 1, x - 1);
addstr("y");
move(y - 1, x - 1);
refresh();
- #ifdef LINUX
- usleep(100000);
- #endif
- #ifdef WINDOWS
- Sleep(100);
- #endif
+ osleep(100);
move(y / 2 - 2, x / 2 - 1);
addstr(".");
for (int i = x - 1; i >= 0; --i)
@@ -519,13 +513,107 @@ void intro()
addstr("y");
move(y - 1, x - 1);
refresh();
- #ifdef LINUX
- usleep(100000);
- #endif
- #ifdef WINDOWS
- Sleep(100);
- #endif
+ osleep(100);
+ }
+}*/
+
+void intro()
+{
+ int x, y;
+ getmaxyx(stdscr, y, x);
+ vector<yeti> dummy;
+ int xtemp[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5,
+ 5, 5, 5, 6, 6, 6, 6, // y
+ 9, 9, 9, 9, 9, 10,10,10,11,11,11, // e
+ 14,15,15,15,15,15,16, // t
+ 19,19,20,20,20,20,20,21,21, // i
+ 24,24,24,24,24,25,26,26,26,26,26, // h
+ 29,29,29,29,30,30,31,31,32,32,32,32, // a
+ 35,35,35,35,35,36,36,37,37, // c
+ 40,40,40,40,40,41,42,42,43,43}; // k
+
+ int ytemp[] = { 0, 1, 2, 3, 0, 1, 2, 3, 2, 3, 4, 5, 6,
+ 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 0,
+ 1, 2, 3, 0, 1, 2, 3, // y
+ 3, 4, 5, 6, 7, 3, 5, 7, 3, 3, 7, // e
+ 3, 3, 4, 5, 6, 7, 3, // t
+ 3, 7, 3, 4, 5, 6, 7, 3, 7, // i
+ 3, 4, 5, 6, 7, 5, 3, 4, 5, 6, 7, // h
+ 4, 5, 6, 7, 3, 5, 3, 5, 4, 5, 6, 7, // a
+ 3, 4, 5, 6, 7, 3, 7, 3, 7, // c
+ 3, 4, 5, 6, 7, 5, 4, 6, 3, 7}; // k
+ int numyetis = 102;
+ vector<int> xs;
+ for (int i = 0; i < numyetis; ++i)
+ {
+ xs.push_back(xtemp[i]);
}
+ for (int i = 0; i < numyetis; ++i)
+ {
+ xs[i] += x / 2 - 21;
+ }
+ vector<int> ys;
+ for (int i = 0; i < numyetis; ++i)
+ {
+ ys.push_back(ytemp[i]);
+ }
+ for (int i = 0; i < numyetis; ++i)
+ {
+ ys[i] += y / 2 - 3;
+ }
+ vector<yeti> yetis;
+ int version = rand() % 2;
+ for (int i = 0; i < numyetis; ++i)
+ {
+ yeti yeti1(rand() % x + 1, rand() % y + 1, x, y);
+ if (version == 0)
+ {
+ yeti1.setx(x / 2 + 1);
+ yeti1.sety(y / 2 + 1);
+ }
+ yetis.push_back(yeti1);
+ }
+ for (int i = 0; i < x; ++i)
+ {
+ for (int j = 0; j < y; ++j)
+ {
+ addch('.');
+ }
+ }
+ refresh();
+ timeout(0);
+ bool done = false;
+ bool reallydone = false;
+ for (int movenum = 0; !done && !reallydone; ++movenum)
+ {
+ for (int numyeti = 0; numyeti < numyetis; ++numyeti)
+ {
+ move(yetis[numyeti].ypos() - 1,yetis[numyeti].xpos() - 1);
+ addch('.');
+ yetis[numyeti].movetowards(xs[numyeti] + 1,ys[numyeti] + 1,dummy,0);
+ move(yetis[numyeti].ypos() - 1,yetis[numyeti].xpos() - 1);
+ addch('y');
+ }
+ osleep(70);
+ refresh();
+ done = true;
+ for (int numyeti = 0; numyeti < numyetis && done; ++numyeti)
+ {
+ if (yetis[numyeti].xpos() - 1 != xs[numyeti])
+ done = false;
+ if (yetis[numyeti].ypos() - 1 != ys[numyeti])
+ done = false;
+ }
+ char input = getch();
+ if (input != ERR)
+ {
+ reallydone = true;
+ }
+ }
+ timeout(-1);
+ if (!reallydone)
+ osleep(2000);
}
int main(int argc, char* argv[])
@@ -537,13 +625,14 @@ int main(int argc, char* argv[])
int a = input;
addstr(convert(a));
}*/
+ srand(time(0));
startCurses();
+ intro();
bool immortal = false;
if (argc > 1 && strcmp(argv[1],"-c") == 0)
{
immortal = true;
}
- srand(time(0));
while(true)
{
menu(immortal);
diff --git a/src/yeti.cpp b/src/yeti.cpp
index dd8c4b5..adaef32 100644
--- a/src/yeti.cpp
+++ b/src/yeti.cpp
@@ -297,3 +297,13 @@ int yeti::absolute(int value)
return value;
}
+int yeti::setx(int newx)
+{
+ x = newx;
+}
+
+int yeti::sety(int newy)
+{
+ y = newy;
+}
+