From 0dd6f0a40334b1fd763f11bb33dd384f111ce110 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 29 Dec 2015 19:43:23 +0100 Subject: [PATCH] Creato nemici e il loro posizionamento. --- main.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 24b89ff..ca3fd38 100644 --- a/main.cpp +++ b/main.cpp @@ -8,13 +8,27 @@ #define Y_MAX 23 #define ROOMS 8 #define ROOM_SIZE 7 +#define ENEMIES_IN_LEVEL 5 #define WALL 0xB2 #define EMPTY 0xFF #define PLAYER 0x02 +#define ENEMY 'X' using namespace std; +//Classe dei nemici +class Enemy +{ + public: + int x; + int y; + void move() + { + //Qui dopo devo metterci il movimento... + } +}; + void move(unsigned char map[X_MAX][Y_MAX], int player[2]) { int player_x = player[0]; @@ -175,7 +189,7 @@ void corridor(unsigned char map[X_MAX][Y_MAX], int start_x, int start_y, int end } } -void generate(unsigned char map[X_MAX][Y_MAX], int player[2]) +void generate(unsigned char map[X_MAX][Y_MAX], int player[2], Enemy* list[ENEMIES_IN_LEVEL]) { int corridor_x; int corridor_y; @@ -204,15 +218,33 @@ void generate(unsigned char map[X_MAX][Y_MAX], int player[2]) map[corridor_x][corridor_y] = PLAYER; } } + for(int e=0; ex = x; + created->y = y; + list[e] = created; + break; + } + } + } } int main() { - unsigned char map[X_MAX][Y_MAX]; //Mappa del gioco + unsigned char map[X_MAX][Y_MAX]; //Mappa del gioco, da usare SOLO per la rappresentazione grafica e per il movimento, non anche per la logica... int player[2]; - srand(time(NULL)); //TODO: Rendere il seed modificabile...? + Enemy* list[ENEMIES_IN_LEVEL]; + srand(0); //TODO: Rendere il seed modificabile...? init(map); - generate(map, player); + generate(map, player, list); draw(map); //Ciclo principale del gioco while(true)