/*
Name: games.h
Copyright:
Author: Tc_xk
Date: 16-02-20 14:51
Description: for dev-c++:NOT offical headfile for game making
*/
#include <iostream>
#include <string>
#include<Windows.h>
#include<cstdlib>
#include<ctime>
#include<stdio.h>
#include<conio.h>
#define up 72
#define down 80
#define left 75
#define right 77
#define LEFT 'a'
#define RIGHT 'd'
#define UP 'w'
#define DOWN 's'
#define Win "====YOU WIN===="
#define Lost "====YOU LOST===="
#define TRUE true
#define FALSE false
using namespace std;//■□●
void map_draw(int s){
srand((unsigned)time(NULL));
int n,a,b;
if(s>=10){
system("color 00") ;
}
else if(s>=8){
system("color fA") ;
}
else if(s>=5){
system("color f9") ;
}
else if(s>=3){
system("color f8") ;
}
else {
system("color f4") ;
}
a=rand()%9+1;
b=rand()%9+1;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
n=rand()%(111-s*10);
if(i==5&&j==5){
cout<<"▲";
}
else if(i==a&&j==b){
if(a==5&&b==5){
a+=1;
b+=1;
}
else{
cout<<"╳ ";
}
}
else if(i==0||j==0||j==9||i==9){
cout<<"■";
}
else if(n<=10){
cout<<"●";
}
else{
cout<<"□";
}
}
cout<<endl;
}
char c;
}
char see(){
while (1){
if(_kbhit()){
return getch();
}
}
}
bool click(char c){
while (1)
{
if (_kbhit()||getch()==c)
{
return true;
}
else return false;
}
}
typedef struct{
int hp;
int x,y;
}player;
typedef struct{
int x,y;
int a,b;
int k,l;
int hp;
char p,f,e,box;
char wall_1,wall_2;
//a & b means the player's position
char map[200][200];
void replace(bool flg){
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
if(i==k&&j==l){
cout<<f;
map[k][l]=f;
}
else if(i==a&&j==b){
cout<<p;
map[i][j]=p;
}
else if(i==0||i==x-1){
cout<<wall_1;
map[i][j]=wall_1;
}
else if(j==0||j==y-1){
cout<<wall_2;
map[i][j]=wall_2;
}
else{
if(flg){
cout<<map[i][j];
}
else{
cout<<box;
map[i][j]==box;
}
}
if(j==y-1){
cout<<endl;
}
}
}
}
void setfinishpoint(){
map[k][l]=f;
}
void getmap(){
cout<<endl;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
cout<<map[i][j];
}
cout<<endl;
}
}
void newpage(int pn){
while(pn--){
cout<<endl;
}
}
void setwall(int sx,int sy,int ex,int ey){
if(sx==ex){
for(int i=sy;i<=ey;i++){
map[sx][i]==wall_1;
}
}
else if(sy==ey){
for(int i=sx;i<=ex;i++){
map[i][sy]==wall_2;
}
}
else{
return;
}
}
void setenemy(int n,int m){
map[n][m]=e;
if(map[n+1][m]==p||map[n-1][m]==p||map[n][m+1]==p||map[n][m-1]==p){
hp--;
if (hp==0)cout<<endl<<"====GAME OVER===="<<endl;
}
}
bool checkfn(){
if(a==k&&b==l){
return true;
}
return false;
}
void sleep(int t){
while(t--){
t=t+1-2+3-2;
}
}
}gmap;
typedef struct {
int x,y;
}pos;
pos search(gmap mp,int a,int b){
pos result;
for (int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(mp.map[i][j]==mp.p){
result.x=i;
result.y=j;
return result;
}
}
}
}
gmap ctrl(gmap aim,char w){
switch (see()){
case LEFT:
if(aim.map[aim.a][aim.b-1]!='|'){
aim.b--;
aim.map[aim.a][aim.b+1]=w;
aim.map[aim.a][aim.b]=aim.p;
}
return aim;
case RIGHT:
if(aim.map[aim.a][aim.b+1]!='|'){
aim.b++;
aim.map[aim.a][aim.b-1]=w;
aim.map[aim.a][aim.b]=aim.p;
}
return aim;
case UP:
if(aim.map[aim.a-1][aim.b]!='-'){
aim.a--;
aim.map[aim.a+1][aim.b]=w;
aim.map[aim.a][aim.b]=aim.p;
}
return aim;
case DOWN:
if(aim.map[aim.a+1][aim.b]!='-'){
aim.a++;
aim.map[aim.a-1][aim.b]=w;
aim.map[aim.a][aim.b]=aim.p;
}
return aim;
default:
return aim;
}
}
void clearmap(gmap &x){
x.x=x.y=x.a=x.b=x.k=x.l=x.hp=0;
x.map[1010][1010]={0};
}
void draw(string s){//total:35 special shapes
if(s=="block_1"){
cout<<"■";
}
else if(s=="block_2"){
cout<<"□";
}
else if(s=="triagl_1"){
cout<<"▲";
}
else if(s=="triagl_2"){
cout<<"△";
}
else if(s=="triagl_3"){
cout<<"▼";
}
else if(s=="triagl_4"){
cout<<"▽";
}
else if(s=="diamond_1"){
cout<<"◆";
}
else if(s=="diamond_2"){
cout<<"◇";
}
else if(s=="circle_1"){
cout<<"○";
}
else if(s=="circle_2"){
cout<<"●";
}
else if(s=="triagl_5"){
cout<<"◢";
}
else if(s=="triagl_6"){
cout<<"◣";
}
else if(s=="triagl_7"){
cout<<"◤";
}
else if(s=="triagl_8"){
cout<<"◥";
}
else if(s=="arrow_1"){
cout<<"←";
}
else if(s=="arrow_2"){
cout<<"↑";
}
else if(s=="arrow_3"){
cout<<"→";
}
else if(s=="arrow_4"){
cout<<"↓";
}
else if(s=="arrow_5"){
cout<<"↖";
}
else if(s=="arrow_6"){
cout<<"↗";
}
else if(s=="arrow_7"){
cout<<"↘";
}
else if(s=="arrow_8"){
cout<<"↙";
}
else if(s=="slash_1"){
cout<<"╱";
}
else if(s=="slash_2"){
cout<<"╲";
}
else if(s=="cross"){
cout<<"╳";
}
else if(s=="circle&cross"){
cout<<"¤";
}
else if(s=="slide_1"){
cout<<"╭";
}
else if(s=="slide_2"){
cout<<"╮";
}
else if(s=="slide_3"){
cout<<"╯";
}
else if(s=="slide_4"){
cout<<"╰";
}
else if(s=="star_1"){
cout<<"★";
}
else if(s=="star_2"){
cout<<"☆";
}
else if(s=="circle_3"){
cout<<"◎";
}
else if(s=="circle_and_dot"){
cout<<"⊙";
}
else if(s=="strange_circle"){
cout<<"⊕";
}
}
typedef struct{
int scr;
void winscore(int s){
scr+=s;
}
void losescore(int s){
scr-=s;
}
void resetscore(int s){
scr=s;
}
void printscore(){
cout<<"GAME SCORE:"<<scr<<endl;
}
bool reachscore(int aimscore){
return scr>=aimscore;
}
void listscoreboard(){
return;//not for this program
}
}score;
typedef struct{
int scr[1000];
int p;
string plynm[1000];
void winscore(int s,string a){
int i=0;
while(i<=1000){
if(plynm[i]==a){
break;
}
if(i==1000){
return;
}
}
scr[i]+=s;
}
void losescore(int s,string a){
int i=0;
while(i<=1000){
if(plynm[i]==a){
break;
}
if(i==1000){
return;
}
}
scr[i]-=s;
}
void resetscore(int s,string a){
int i=0;
while(i<=1000){
if(plynm[i]==a){
break;
}
if(i==1000){
return;
}
}
scr[i]=s;
}
void listscoreboard(){
cout<<"SCORES:\n";
for(int i=0;i<p;i++){
cout<<plynm[i]<<":"<<scr[i]<<"\n";
}
}
}scoreboard;
typedef struct {
string name;
int atk;
//~~~
int drb;
//~~~
int def;
}tool;
typedef struct{
string name;
int cost;
bool sold;
void start(tool a,int c){
name=a.name;
cost=c;
sold=false;
}
}shop;
typedef struct{
int mny;
void moneyset(int m){
mny=m;
}
void gotmoney(int m){
mny+=m;
}
void usemoney(int m){
mny-=m;
}
void showmoney(){
cout<<"USABLE MONEY:"<<mny<<endl;
}
}money;
struct flagset{
bool a;
string p;
void reset(bool msg,string set){
a=msg;
p=set;
}
void ctrl(){
int c;
if(p=="switch"){
a=1-a;
}
if(p=="true"){
a=true;
}
if(p=="false"){
a=false;
}
}
};
typedef struct{
string obj[1000];
int cnt;
void clearpack(){
for(int i=0;i<cnt;i++){
obj[i]=" ";
}
cnt=0;
}
string buy(money &x,shop &a){
x.usemoney(a.cost);
a.sold=true;
obj[cnt]=a.name;
cnt++;
}
string use(string a){
for(int i=0;i<cnt;i++){
if(obj[i]==a){
cnt--;
return "use";
}
}
}
}pack;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~