Map.cpp

 avatar
user_6225994
plain_text
a year ago
645 B
3
Indexable
#include "Map.h"
#include <iostream>

using namespace std;

Map::Map(){
	_w = 100;
	_h = 50;
	char **p = new char*[_h];
	for (int r = 0; r < _h; r++){
		p[r] = new char[_w];
		for (int c = 0; c < _w; c++){
			if (r == 0 || c == 0 || r == _h - 1 || c == _w - 1){
				p[r][c] = '#';
			}else{
				p[r][c] = ' ';
			}
		}
	}
	_map = p;
}

void Map::DisPlayMap(){
	for (int r = 0; r < _h; r++){
		for (int c = 0; c < _w; c++){
			cout << _map[r][c];
		}
		cout << endl;
	}
}

Map::~Map()
{
	char **p = _map;
	for (int r = 0; r < _h; r++){
		delete[] _map[r];
	}
	delete[] _map;
	_map = 0;
	_h = 0;
	_w = 0;
}