Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <windows.h>
- #include "enemy.h"
- #include "fight.h"
- #include "game.h"
- #include <random>
- #include <cstdlib>
- #include <ctime>
- #include <cstdio>
- using namespace std;
- game::game()
- {
- //ctor
- }
- void game::mainSys(){
- system("color f0");
- char map[10][25];
- fight f;
- char ploc;
- int steps = 0;
- int score = 0;
- int points = 0;
- bool isDone = false;
- bool key = false;
- int speed = 0;
- switch(level){
- case 0:{
- char map[10][25] = { "#W/A/S/D############",
- "#@ PLAY#",
- "# #######",
- "# INST#",
- "# #######",
- "# CRED#",
- "# #######",
- "# QUIT#",
- "####################"};
- }break;
- case 1:{
- char map[10][25] = {"####################",
- "#@ 99 # # 9#",
- "#### # 2 9# # 2 #",
- "# # ##### ## 2 9 #",
- "#9 999 ######",
- "#9 ####### ##2 #",
- "#9 #2 # 99 #",
- "#k #### # ### #####",
- "# 2 9 # 9 2!#",
- "####################"};
- }break;
- case 2:{
- char map[10][25] = {"loominaty#",
- " #2#",
- " #2 2#",
- " # #",
- " # 9 #",
- " # 99k99 #",
- " #2 9 #",
- " # 2 #",
- " #@ !#",
- "###################"};
- }break;
- case 3:
- {
- char map[10][25] = {" ##################",
- "#99 29k#",
- "#9 2 9#",
- "# ## ## 2 #",
- "# ## 2## #",
- "# 2 ! #",
- "# ################ #",
- "#9@ ############ 9#",
- "#99 2 99#",
- " ##################"};
- }break;
- case 4:{
- char map[10][25] = { "####################",
- "#@ 9 2#",
- "################## #",
- "###! 2 # #",
- "################ # #",
- "################ #2#",
- "# 2# #",
- "# ################k#",
- "#2 9 2#",
- "####################"};
- }break;
- case 5:{
- char map[10][25] = { "####################",
- "#@ 2 !###",
- "# ############## k#",
- "# ########## 2 #",
- "# 92######## 9 #",
- "# ######## 2 #",
- "# 2 ########## #",
- "# ############## #",
- "# 2 9 2 #",
- "####################"};
- }break;
- case 6:{
- char map[10][25] = { "####################",
- "##@ 2 #",
- "#!# 2 ## 2 #### #",
- "# # #2# ########",
- "## ##### # ##### #",
- "### 9 ### #",
- "#### 2 ## 9 2#",
- "##### ##### 2 # #",
- "###############k #",
- "####################"};
- }break;
- case 7:{
- char map[10][25] = { "####################",
- "##### 2 2 #####",
- "####### #######",
- "######2 # # ######",
- "##### ## 2## #####",
- "#### ### ### ####",
- "### #### #### 2###",
- "## ##### 2##### ##",
- "#@9######k9######9!#",
- "####################"};
- }break;
- case 8:{
- char map[10][25] = { "####################",
- "#99999999##99999999#",
- "#999999##@ ##999999#",
- "#9999##2 2##9999#",
- "#99##! 2 k##99#",
- "#9999## 2 2 ##9999#",
- "#999999## ##999999#",
- "#99999999##99999999#",
- "####################"};
- }break;
- case 9:{
- char map[10][25] = { "####################",
- "# 2 2 !#",
- "# ## ## ## #",
- "# ##@ ## ## # ## #",
- "# ###### 2 ### #",
- "# ###### ## ### #",
- "# ##k ## ## # ## #",
- "# ## 2## ## 2 #",
- "# 2 #",
- "####################"};
- }break;
- case 10:{
- char map[10][25] = { "####################",
- "# #",
- "# THANKS #",
- "# FOR@ #",
- "# PLAYING! #",
- "# #",
- "# #",
- "# #",
- "# #",
- "####################"};
- }break;
- case 11:{
- system("cls");
- cout << "aha... So you discovered the secret level. Good Job" << endl;
- system("pause");
- char map[10][25] = { "####################",
- "#2#@k999999999999#2#",
- "###99999999999999###",
- "#999999999999999999#",
- "#999999999999999999#",
- "#999999999999999999#",
- "#999999999999999999#",
- "###99999999999999###",
- "#2#9999999999999!#2#",
- "####################"};
- }break;
- case 12:
- {
- cout << "YOU WIN!!!!!!!!!!!!!" << endl;
- Sleep(2000);
- system("pause");
- *lvl = 1;
- mainSys();
- }break;
- }
- while(isDone == false){
- Sleep(50);
- cout << string(100,'\n');
- for(int y = 0; y <10; y++){
- cout << map[y] << endl;
- }
- for(int y = 0; y < 10; y++){
- for(int x = 0; x < 25; x++){
- char level = map[y][x];
- switch(level){
- case '@':{
- map[y][x] = 1;}
- break;
- case '#':
- {map[y][x] = 219;}
- break;
- case '!':
- {if(key==true){map[y][x] = 3;}}
- break;
- case '2':
- {map[y][x] = 2;
- case 2:
- int movems = movement();
- switch(movems){
- case 1:{
- Sleep(speed + 200);
- int y2=y-1;
- switch(map[y2][x]){
- case ' ':
- {
- map[y][x] = ' ';
- y-=1;
- map[y2][x] = 2;
- }break;
- case 1:{
- f.war();
- map[y][x] = ' ';
- points++;
- score+=10;
- }
- }
- }
- break;
- case 2:{
- Sleep(speed);
- int y2=y+1;
- switch(map[y2][x]){
- case ' ':
- {
- map[y][x] = ' ';
- y+=1;
- map[y2][x] = 2;
- }break;
- case 1:{
- f.war();
- map[y][x] = ' ';
- points++;
- score+=10;
- }
- }
- }break;
- case 3:{
- Sleep(speed + 200);
- int x2=x-1;
- switch(map[y][x2]){
- case ' ':
- {
- map[y][x] = ' ';
- x-=1;
- map[y][x2] = 2;
- }break;
- case 1:{
- f.war();
- map[y][x] = ' ';
- points++;
- score+=10;
- }
- }
- }break;
- case 4:{
- Sleep(speed + 200);
- int x2=x+1;
- switch(map[y][x2]){
- case ' ':
- {
- map[y][x] = ' ';
- x+=1;
- map[y][x2] = 2;
- }break;
- case 1:{
- f.war();
- map[y][x] = ' ';
- points++;
- score+=10;
- }
- }
- }break;
- }
- }
- break;
- case '9':
- {map[y][x] = 4;}
- }
- switch(level){
- case 1:{
- char input;
- if(GetAsyncKeyState('D') != 0){
- input = 'd';
- }
- if(GetAsyncKeyState('A') != 0){
- input = 'a';
- }
- if(GetAsyncKeyState('W') !=0){
- input = 'w';
- }
- if(GetAsyncKeyState('S') != 0){
- input = 's';
- }
- switch(input){
- case 'w':
- case 'W':
- input = NULL;
- Sleep(speed);
- {int y2 = y-1;
- switch(map[y2][x]){
- break;
- case 2:{
- map[y2][x] = ' ';
- f.war();
- points++;
- score+=10;}
- break;
- case 4:
- score+=5;
- case ' ':
- steps++;
- map[y][x] = ' ';
- y-=1;
- map[y2][x] = 1;
- break;
- case 'K':
- case 'k':{
- map[y][x] = ' ';
- map[y2][x] = 1;
- key = true;
- }break;
- case 3:
- {if(key==true){system("cls");
- *lvl+=1;
- mainSys();}}}}
- break;
- break;
- case 's':
- case 'S':
- input = NULL;
- Sleep(speed);
- {int y2 = y+1;
- switch(map[y2][x]){
- break;
- case 2:{
- map[y2][x] = ' ';
- f.war();
- points++;
- score+=10;}
- break;
- case 4:
- score+=5;
- case ' ':
- steps++;
- map[y][x] = ' ';
- y+=1;
- map[y2][x] = 1;
- break;
- case 'K':
- case 'k':{
- map[y][x] = ' ';
- map[y2][x] = 1;
- key = true;
- }break;
- case 3:
- {if(key==true){system("cls");
- *lvl+=1;
- mainSys();}}}}
- break;
- case 'd':
- case 'D':
- input = NULL;
- Sleep(speed);
- {int x2 = x+1;
- switch(map[y][x2]){
- case 'P':{
- *lvl+=1;
- mainSys();
- }break;
- case 'I':{
- system("cls");
- cout << "Use W/S/A/D to move" << endl;
- cout << "Collect (k)eys to unlock next level" << endl;
- cout << "bumping into enemies (2) takes you to battle" << endl;
- cout << "When you die, you are dead for good" << endl;
- system("pause");
- mainSys();
- }break;
- case 'C':{
- system("cls");
- cout << "Game made by nuvindu with c++" << endl;
- cout << "made in Code::Blocks" << endl;
- cout << "2015" << endl;
- system("pause");
- mainSys();
- }break;
- case 'Q':{
- exit(0);
- }break;
- case 2:{
- map[y][x2] = ' ';
- f.war();
- points++;
- score+=10;}
- break;
- case 4:
- score+=5;
- case ' ':
- steps++;
- map[y][x] = ' ';
- x+=1;
- map[y][x2] = 1;
- break;
- case 'K':
- case 'k':{
- map[y][x] = ' ';
- map[y][x2] = 1;
- key = true;
- }break;
- case 3:
- {if(key==true){system("cls");
- *lvl+=1;
- mainSys();}}}}
- break;
- case 'a':
- case 'A':
- input = NULL;
- Sleep(speed);
- {int x2 = x-1;
- switch(map[y][x2]){
- break;
- case 2:{
- map[y][x2] = ' ';
- f.war();
- points++;
- score+=10;}
- break;
- case 4:
- score+=5;
- case ' ':
- steps++;
- map[y][x] = ' ';
- x-=1;
- map[y][x2] = 1;
- break;
- case 'K':
- case 'k':{
- map[y][x] = ' ';
- map[y][x2] = 1;
- key = true;
- }break;
- case 3:
- {if(key==true){system("cls");
- *lvl+=1;
- mainSys();}}}}
- break;
- }
- }
- break;
- }
- }
- }
- }
- }
- int game::movement(){
- int i =1+ (rand() + time(0)) %4;
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement