1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#ifndef GAME_H
#define GAME_H
#include<iostream>
#include<conio.h>
#include"movment.h"
#include"system.h"
using namespace std;
void rand_apple(char arr[YLEN][XLEN])
{
int x=xran(),y=yran();
arr[y][x]=APPLE;
}
void classic_mode()
{
char board[YLEN][XLEN];
int x=xran(),y=yran();
char d;
setdelay();
clear(board);
do
{
d=randomize();
}
while(!direction_is_good(x,y,d));
rand_apple(board);
board[y][x]=NOTE;
do
{
do
{
c();
if(eat(board,x,y,d))
{
++score;
rand_apple(board);
}
place(board,x,y,d);
b(beep);
print(board);
if(show)
{
cout<<"x="<<x<<" y="<<y<<endl;
printd(d);
}
Sleep(delay);
}
while(!_kbhit()&&!endboard(x,y));
if(!endboard(x,y))
d=_getch();
}
while(!endboard(x,y)&&score<MAX_SCORE);
cout<<endl;
if(score>=MAX_SCORE)cout<<"you win!!! \1\n";
else cout<<"you lose and your score is "<<score<<".\n";
p();
}
void endless_mode()
{
char board[YLEN][XLEN];
int x=xran(),y=yran(),score=0;
char d;
setdelay();
clear(board);
do
{
d=randomize();
}
while(!direction_is_good(x,y,d));
rand_apple(board);
while(direction_is_good(x,y,d)&&score<MAX_SCORE)
{
c();
while(!_kbhit())
{
place(board,x,y,d);
Sleep(delay);
}
d=_getch();
if(eat(board,x,y,d))
{
++score;
rand_apple(board);
}
}
c();
print(board);
if(score>=MAX_SCORE)cout<<"you win!!! \1\n";
else cout<<"you lose and your score is "<<score<<".\n";
p();
}
void instruc(){}
void run_simulator()
{
char arr[YLEN][XLEN],d;
clear(arr);
int x=xran(),y=yran();
rand_apple(arr);
while(!_kbhit())
{
do
{
d=randomize();
}
while(!direction_is_good(x,y,d));
if(eat(arr,x,y,d))
{
++score;
rand_apple(arr);
}
place(arr,x,y,d);
c();
cout<<"\t\t\tthe moving thing!!!(simulator)\n";
print(arr);
cout<<"Press any key to continue...";
Sleep(700);
}
_getch();
}
#endif
|