From 842a55e4f6002ecd47d507aa7303895c726b3c1a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 30 Dec 2015 16:25:23 +0100 Subject: [PATCH] =?UTF-8?q?Aggiunti=20pi=C3=B9=20piani=20e=20passaggi=20al?= =?UTF-8?q?=20successivo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index e3176d7..f80faac 100644 --- a/main.cpp +++ b/main.cpp @@ -14,12 +14,16 @@ #define EMPTY 0xFF #define PLAYER 0x02 #define ENEMY 'X' +#define EXIT '>' using namespace std; //Mappa del gioco unsigned char map[X_MAX][Y_MAX]; +//Numero del piano raggiunto dal giocatore +int depth = 1; + //Classe dei nemici class Enemy { @@ -85,7 +89,7 @@ class Enemy }; //Fai muovere il giocatore -void move(int player[2]) +int move(int player[2]) { int player_x = player[0]; int player_y = player[1]; @@ -106,6 +110,10 @@ void move(int player[2]) player_y--; waiting = false; } + else if(map[player_x][player_y-1] == EXIT) + { + return 1; + } break; case 80: //Freccia giĆ¹ if(map[player_x][player_y+1] == EMPTY) @@ -115,6 +123,10 @@ void move(int player[2]) player_y++; waiting = false; } + else if(map[player_x][player_y+1] == EXIT) + { + return 1; + } break; case 75: //Freccia sinistra if(map[player_x-1][player_y] == EMPTY) @@ -124,6 +136,10 @@ void move(int player[2]) player_x--; waiting = false; } + else if(map[player_x-1][player_y] == EXIT) + { + return 1; + } break; case 77: //Freccia destra if(map[player_x+1][player_y] == EMPTY) @@ -133,6 +149,10 @@ void move(int player[2]) player_x++; waiting = false; } + else if(map[player_x+1][player_y] == EXIT) + { + return 1; + } break; } } @@ -144,6 +164,7 @@ void move(int player[2]) } player[0] = player_x; player[1] = player_y; + return 0; } //Aggiorna la console con la situazione corrente del gioco. void draw() @@ -157,6 +178,7 @@ void draw() cout << map[x][y]; } } + cout << "Piano " << depth; } //Funzioni per la generazione della mappa @@ -280,6 +302,7 @@ void generate(int player[2], Enemy* list[ENEMIES_IN_LEVEL]) map[corridor_x][corridor_y] = PLAYER; } } + //Posizionamento nemici for(int e=0; e