summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-06 22:13:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-06 22:13:39 +0000
commit87b7dec3f5978893d897e1d61ddaf0e793a33b05 (patch)
tree4c96f6b1f6e164bc80b9db511a7314564d90a3fb
parent819c303db467086d714ad663b285b44cde6329cf (diff)
downloadMana-87b7dec3f5978893d897e1d61ddaf0e793a33b05.tar.gz
Mana-87b7dec3f5978893d897e1d61ddaf0e793a33b05.tar.bz2
Mana-87b7dec3f5978893d897e1d61ddaf0e793a33b05.tar.xz
Mana-87b7dec3f5978893d897e1d61ddaf0e793a33b05.zip
Added setSize function to Map.
-rw-r--r--docs/items.txt6
-rw-r--r--src/map.cpp12
-rw-r--r--src/map.h5
3 files changed, 20 insertions, 3 deletions
diff --git a/docs/items.txt b/docs/items.txt
index 3ebccb1f..beaa2ab1 100644
--- a/docs/items.txt
+++ b/docs/items.txt
@@ -31,5 +31,7 @@ of items. An item can have the following properties:
Every being will have a variable number of slots to equip items. For a player
we will have 6 slots: head, upper body, lower body, feet, left hand, right
hand.
-To equip an item you should go to the inventory, select the desired item and push the "Equip"
-button. To uneqip, push the "Unequip" button in the equipment window. Unequipped items should automatically go back in the inventory. \ No newline at end of file
+
+To equip an item you should go to the inventory, select the desired item and
+push the "Equip" button. To unequip, push the "Unequip" button in the equipment
+window. Unequipped items should automatically go back in the inventory.
diff --git a/src/map.cpp b/src/map.cpp
index d2b1590e..a9437f9f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -80,7 +80,7 @@ Tile::Tile():
Map::Map():
- width(200), height(200)
+ width(0), height(0)
{
tiles = new Tile[width * height];
}
@@ -102,6 +102,8 @@ bool Map::load(char *mapFile) {
fread(&oldMap, sizeof(MAP), 1, file);
fclose(file);
+ setSize(OLD_MAP_WIDTH, OLD_MAP_HEIGHT);
+
// Transfer tile data
int x, y;
for (y = 0; y < OLD_MAP_HEIGHT; y++) {
@@ -134,6 +136,14 @@ bool Map::load(char *mapFile) {
return true;
}
+void Map::setSize(int width, int height)
+{
+ this->width = width;
+ this->height = height;
+ delete[] tiles;
+ tiles = new Tile[width * height];
+}
+
void Map::setWalk(int x, int y, bool walkable) {
if (walkable) {
tiles[x + y * width].flags |= TILE_WALKABLE;
diff --git a/src/map.h b/src/map.h
index 79a3ea36..be0364d7 100644
--- a/src/map.h
+++ b/src/map.h
@@ -64,6 +64,11 @@ class Map
bool load(char *mapFile);
/**
+ * Sets the size of the map. This will destroy any existing map data.
+ */
+ void setSize(int width, int height);
+
+ /**
* Set tile ID.
*/
void setTile(int x, int y, int layer, int id);