diff --git a/Data/Media/Maps/map b/Data/Media/Maps/map
index 4e531f8..78cc7d6 100644
--- a/Data/Media/Maps/map
+++ b/Data/Media/Maps/map
@@ -9,7 +9,7 @@
100
-null
+map
0
0
@@ -18,7 +18,7 @@
ice
false
-tree
+openChest
true
100
diff --git a/Data/Media/Maps/map2 b/Data/Media/Maps/map2
new file mode 100644
index 0000000..cb63eef
--- /dev/null
+++ b/Data/Media/Maps/map2
@@ -0,0 +1,61 @@
+
diff --git a/Unuk-QT/Makefile b/Unuk-QT/Makefile
index fb71f52..bdb4df8 100644
--- a/Unuk-QT/Makefile
+++ b/Unuk-QT/Makefile
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: Unuk-QT
-# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Dec 14 00:58:57 2011
+# Generated by qmake (2.01a) (Qt 4.7.3) on: Fri Dec 16 01:33:02 2011
# Project: Unuk-QT.pro
# Template: app
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
@@ -66,7 +66,8 @@ SOURCES = ../src/libUnuk/Debug.cpp \
../src/libUnuk/NPC.cpp \
../src/Unuk/Player.cpp \
../src/Unuk/Game.cpp \
- ../src/libUnuk/Entity.cpp
+ ../src/libUnuk/MapElement.cpp \
+ ../src/libUnuk/MapEntities.cpp
OBJECTS = Debug.o \
main.o \
Input.o \
@@ -90,7 +91,8 @@ OBJECTS = Debug.o \
NPC.o \
Player.o \
Game.o \
- Entity.o
+ MapElement.o \
+ MapEntities.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
@@ -190,7 +192,7 @@ qmake: FORCE
dist:
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h ../src/libUnuk/Text.h ../src/libUnuk/MapTile.h ../src/libUnuk/Map.h ../src/libUnuk/Button.h ../src/libUnuk/ButtonToggle.h ../src/libUnuk/Menu.h ../src/libUnuk/MainMenu.h ../src/libUnuk/ParticleEmitter.h ../src/libUnuk/IngameMenu.h ../src/libUnuk/Collision.h ../src/libUnuk/Character.h ../src/libUnuk/NPC.h ../src/Unuk/Player.h ../src/Unuk/Game.h ../src/libUnuk/Entity.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp ../src/libUnuk/Text.cpp ../src/libUnuk/Map.cpp ../src/libUnuk/Button.cpp ../src/libUnuk/ButtonToggle.cpp ../src/libUnuk/ParticleEmitter.cpp ../src/libUnuk/MainMenu.cpp ../src/libUnuk/IngameMenu.cpp ../src/libUnuk/Collision.cpp ../src/libUnuk/Character.cpp ../src/libUnuk/NPC.cpp ../src/Unuk/Player.cpp ../src/Unuk/Game.cpp ../src/libUnuk/Entity.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.h ../src/Libs/wglext.h ../src/Libs/glxext.h ../src/libUnuk/Input.h ../src/libUnuk/Rect.h ../src/libUnuk/Timer.h ../src/libUnuk/Font.h ../Constants.h ../src/Unuk/Constants.h ../src/libUnuk/ApplySurface.h ../src/Unuk/Globals.h ../src/libUnuk/ImageLoader.h ../src/libUnuk/TextureManager.h ../src/libUnuk/Texture.h ../src/libUnuk/Text.h ../src/libUnuk/MapTile.h ../src/libUnuk/Map.h ../src/libUnuk/Button.h ../src/libUnuk/ButtonToggle.h ../src/libUnuk/Menu.h ../src/libUnuk/MainMenu.h ../src/libUnuk/ParticleEmitter.h ../src/libUnuk/IngameMenu.h ../src/libUnuk/Collision.h ../src/libUnuk/Character.h ../src/libUnuk/NPC.h ../src/Unuk/Player.h ../src/Unuk/Game.h ../src/libUnuk/MapElement.h ../src/libUnuk/MapEntities.h .tmp/Unuk-QT1.0.0/ && $(COPY_FILE) --parents ../src/libUnuk/Debug.cpp ../src/Unuk/main.cpp ../src/libUnuk/Input.cpp ../src/libUnuk/Timer.cpp ../src/libUnuk/Font.cpp ../src/libUnuk/ApplySurface.cpp ../src/Unuk/Globals.cpp ../src/libUnuk/Rect.cpp ../src/libUnuk/ImageLoader.cpp ../src/libUnuk/TextureManager.cpp ../src/libUnuk/Texture.cpp ../src/libUnuk/Text.cpp ../src/libUnuk/Map.cpp ../src/libUnuk/Button.cpp ../src/libUnuk/ButtonToggle.cpp ../src/libUnuk/ParticleEmitter.cpp ../src/libUnuk/MainMenu.cpp ../src/libUnuk/IngameMenu.cpp ../src/libUnuk/Collision.cpp ../src/libUnuk/Character.cpp ../src/libUnuk/NPC.cpp ../src/Unuk/Player.cpp ../src/Unuk/Game.cpp ../src/libUnuk/MapElement.cpp ../src/libUnuk/MapEntities.cpp .tmp/Unuk-QT1.0.0/ && (cd `dirname .tmp/Unuk-QT1.0.0` && $(TAR) Unuk-QT1.0.0.tar Unuk-QT1.0.0 && $(COMPRESS) Unuk-QT1.0.0.tar) && $(MOVE) `dirname .tmp/Unuk-QT1.0.0`/Unuk-QT1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Unuk-QT1.0.0
clean:compiler_clean
@@ -237,28 +239,28 @@ Debug.o: ../src/libUnuk/Debug.cpp ../src/libUnuk/Debug.h
main.o: ../src/Unuk/main.cpp ../src/libUnuk/MainMenu.h \
../src/Unuk/Constants.h \
- ../src/libUnuk/Menu.h \
- ../src/Unuk/Globals.h \
../src/libUnuk/Button.h \
+ ../src/Unuk/Globals.h \
../src/libUnuk/Input.h \
../src/libUnuk/Text.h \
../src/libUnuk/ApplySurface.h \
../src/libUnuk/Debug.h \
../src/libUnuk/Font.h \
../src/libUnuk/Rect.h \
- ../src/libUnuk/ButtonToggle.h \
../src/libUnuk/Map.h \
../src/libUnuk/ImageLoader.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h \
../src/libUnuk/NPC.h \
../src/libUnuk/Character.h \
../src/libUnuk/Collision.h \
../src/libUnuk/Timer.h \
../src/Unuk/Game.h \
../src/Unuk/Player.h \
- ../src/libUnuk/IngameMenu.h
+ ../src/libUnuk/IngameMenu.h \
+ ../src/libUnuk/ButtonToggle.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../src/Unuk/main.cpp
Input.o: ../src/libUnuk/Input.cpp ../src/libUnuk/Input.h
@@ -316,9 +318,10 @@ Map.o: ../src/libUnuk/Map.cpp ../src/libUnuk/Map.h \
../src/libUnuk/ImageLoader.h \
../src/libUnuk/Debug.h \
../src/libUnuk/ApplySurface.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Map.o ../src/libUnuk/Map.cpp
Button.o: ../src/libUnuk/Button.cpp ../src/libUnuk/Button.h \
@@ -351,25 +354,23 @@ ParticleEmitter.o: ../src/libUnuk/ParticleEmitter.cpp ../src/libUnuk/ParticleEmi
MainMenu.o: ../src/libUnuk/MainMenu.cpp ../src/libUnuk/MainMenu.h \
../src/Unuk/Constants.h \
- ../src/libUnuk/Menu.h \
- ../src/Unuk/Globals.h \
../src/libUnuk/Button.h \
+ ../src/Unuk/Globals.h \
../src/libUnuk/Input.h \
../src/libUnuk/Text.h \
../src/libUnuk/ApplySurface.h \
../src/libUnuk/Debug.h \
../src/libUnuk/Font.h \
../src/libUnuk/Rect.h \
- ../src/libUnuk/ButtonToggle.h \
../src/libUnuk/Map.h \
../src/libUnuk/ImageLoader.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o MainMenu.o ../src/libUnuk/MainMenu.cpp
IngameMenu.o: ../src/libUnuk/IngameMenu.cpp ../src/libUnuk/IngameMenu.h \
- ../src/libUnuk/Menu.h \
../src/Unuk/Globals.h \
../src/Unuk/Constants.h \
../src/libUnuk/Button.h \
@@ -393,9 +394,10 @@ Character.o: ../src/libUnuk/Character.cpp ../src/libUnuk/Character.h \
../src/libUnuk/ImageLoader.h \
../src/libUnuk/Collision.h \
../src/libUnuk/Map.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h \
../src/libUnuk/Timer.h \
../src/libUnuk/Text.h \
../src/libUnuk/Font.h
@@ -410,9 +412,10 @@ NPC.o: ../src/libUnuk/NPC.cpp ../src/libUnuk/NPC.h \
../src/libUnuk/ImageLoader.h \
../src/libUnuk/Collision.h \
../src/libUnuk/Map.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h \
../src/libUnuk/Timer.h \
../src/libUnuk/Text.h \
../src/libUnuk/Font.h
@@ -427,9 +430,10 @@ Player.o: ../src/Unuk/Player.cpp ../src/Unuk/Player.h \
../src/libUnuk/ImageLoader.h \
../src/libUnuk/Collision.h \
../src/libUnuk/Map.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h \
../src/libUnuk/Timer.h \
../src/libUnuk/Text.h \
../src/libUnuk/Font.h
@@ -445,14 +449,14 @@ Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \
../src/libUnuk/ImageLoader.h \
../src/libUnuk/Collision.h \
../src/libUnuk/Map.h \
- ../src/libUnuk/TextureManager.h \
../src/libUnuk/MapTile.h \
- ../src/libUnuk/Entity.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/MapEntities.h \
../src/libUnuk/Timer.h \
../src/libUnuk/Text.h \
../src/libUnuk/Font.h \
../src/libUnuk/IngameMenu.h \
- ../src/libUnuk/Menu.h \
../src/libUnuk/Button.h \
../src/libUnuk/Input.h \
../src/libUnuk/Rect.h \
@@ -460,8 +464,22 @@ Game.o: ../src/Unuk/Game.cpp ../src/Unuk/Game.h \
../src/libUnuk/NPC.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Game.o ../src/Unuk/Game.cpp
-Entity.o: ../src/libUnuk/Entity.cpp ../src/libUnuk/Entity.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Entity.o ../src/libUnuk/Entity.cpp
+MapElement.o: ../src/libUnuk/MapElement.cpp ../src/libUnuk/MapElement.h \
+ ../src/Unuk/Globals.h \
+ ../src/libUnuk/ApplySurface.h \
+ ../src/libUnuk/Debug.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/ImageLoader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o MapElement.o ../src/libUnuk/MapElement.cpp
+
+MapEntities.o: ../src/libUnuk/MapEntities.cpp ../src/libUnuk/MapEntities.h \
+ ../src/libUnuk/MapElement.h \
+ ../src/Unuk/Globals.h \
+ ../src/libUnuk/ApplySurface.h \
+ ../src/libUnuk/Debug.h \
+ ../src/libUnuk/TextureManager.h \
+ ../src/libUnuk/ImageLoader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o MapEntities.o ../src/libUnuk/MapEntities.cpp
####### Install
diff --git a/Unuk-QT/Unuk-QT.pro b/Unuk-QT/Unuk-QT.pro
index 5dbd7ae..ede7d73 100644
--- a/Unuk-QT/Unuk-QT.pro
+++ b/Unuk-QT/Unuk-QT.pro
@@ -35,7 +35,8 @@ HEADERS += ../src/libUnuk/Debug.h \
../src/libUnuk/NPC.h \
../src/Unuk/Player.h \
../src/Unuk/Game.h \
- ../src/libUnuk/Entity.h
+ ../src/libUnuk/MapElement.h \
+ ../src/libUnuk/MapEntities.h
SOURCES += ../src/libUnuk/Debug.cpp \
../src/Unuk/main.cpp \
../src/libUnuk/Input.cpp \
@@ -59,4 +60,5 @@ SOURCES += ../src/libUnuk/Debug.cpp \
../src/libUnuk/NPC.cpp \
../src/Unuk/Player.cpp \
../src/Unuk/Game.cpp \
- ../src/libUnuk/Entity.cpp
+ ../src/libUnuk/MapElement.cpp \
+ ../src/libUnuk/MapEntities.cpp
diff --git a/src/libUnuk/Character.cpp b/src/libUnuk/Character.cpp
index 3de7c58..27bcdca 100644
--- a/src/libUnuk/Character.cpp
+++ b/src/libUnuk/Character.cpp
@@ -151,9 +151,14 @@ void Character::Move(void) {
if(CheckCharacterCollisions()) y -= yVel;
}
+/*
+ * Bounds checking only included in map.GetTileSolidity() and
+ * map.GetEntitySolidity(). Remember to add bounds checking
+ * if any other map method is used in a similar manner.
+ */
bool Character::CheckTileCollisions(void) {
- for(int i = -2; i < 3; i++) {
- for(int j = -2; j < 3; j++) {
+ for(int i = -1; i < 2; i++) {
+ for(int j = -1; j < 2; j++) {
if(map->GetTileSolidity(tileX + i, tileY + j))
if(CheckCollisionXY(x, y, w, h, map->GetTileX(tileX + i, tileY + j),
map->GetTileY(tileX + i, tileY + j), TILE_WIDTH, TILE_HEIGHT))
diff --git a/src/libUnuk/Entity.cpp b/src/libUnuk/Entity.cpp
deleted file mode 100644
index 8fb9f04..0000000
--- a/src/libUnuk/Entity.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "Entity.h"
diff --git a/src/libUnuk/Entity.h b/src/libUnuk/Entity.h
deleted file mode 100644
index 092a5c6..0000000
--- a/src/libUnuk/Entity.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _ENTITY_H_
-#define _ENTITY_H_
-
-class Entity {
-public:
-
-private:
- bool m_solid;
-
- int x;
- int y;
- int w;
- int h;
-};
-
-#endif
diff --git a/src/libUnuk/Map.cpp b/src/libUnuk/Map.cpp
index 3bb5653..5a3a187 100644
--- a/src/libUnuk/Map.cpp
+++ b/src/libUnuk/Map.cpp
@@ -25,8 +25,8 @@ void Map::Load(const string filename) {
// We will set x and y positions to zero for now, as we
// are going to set them withing the XML file.
- x = 0;
- y = 0;
+ x = -1;
+ y = -1;
//
- levelWidth = (x - 1) * TILE_WIDTH;
- levelHeight = (y - 1) * TILE_HEIGHT;
+ levelWidth = x * TILE_WIDTH;
+ levelHeight = y * TILE_HEIGHT;
//character->Load(filename);
}
void Map::Render(void) {
- for(int j = 1; j < x; j++)
- for(int i = 1; i < y; i++) {
- ApplySurface(m_tile[j][i].GetTileX(), m_tile[j][i].GetTileY(), m_tile[j][i].GetTileTexture(), screen);
+ int xOrig = (camera.x / TILE_WIDTH);
+ int yOrig = (camera.y / TILE_HEIGHT);
- if(m_tile[j][i].GetEntityTexture() != NULL)
- ApplySurface(m_tile[j][i].GetEntityX(), m_tile[j][i].GetEntityY(), m_tile[j][i].GetEntityTexture(), screen);
- }
- return;
-
- int xOrig = (camera.x / TILE_WIDTH) + 1;
- int yOrig = (camera.y / TILE_HEIGHT) + 1;
-
- int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH);
- int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT);
+ int xEnd = (SCREEN_WIDTH / TILE_WIDTH);
+ int yEnd = (SCREEN_HEIGHT / TILE_HEIGHT);
if(xEnd < x)
xEnd++;
+ else
+ xEnd = x;
+
if(yEnd < y)
yEnd++;
+ else
+ yEnd = y;
- for(int j = 1; j < xEnd; j++)
- for(int i = 1; i < yEnd; i++) {
- ApplySurface(m_tile[j][i].GetTileX(), m_tile[j][i].GetTileY(),
- m_tile[j][i].GetTileTexture(), screen);
- if(m_tile[j][i].GetEntityTexture() != NULL) {
- Debug::logger->message("Entity");
- ApplySurface(m_tile[j][i].GetEntityX(), m_tile[j][i].GetEntityY(),
- m_tile[j][i].GetEntityTexture(), screen);
+ for(int i = xOrig; i < xEnd; i++) {
+ for(int j = yOrig; j < yEnd; j++) {
+ m_tile[i][j].Render();
}
}
}
@@ -168,66 +157,60 @@ void Map::Render(void) {
void Map::Unload(void) {
m_tileTextures.Unload();
m_entityTextures.Unload();
-
- for(int i = 0; i < TILE_ARRAY_SIZE; i++) {
- for(int j = 0; j < TILE_ARRAY_SIZE; j++) {
- m_tile[i][j].SetTileTexture(NULL);
- m_tile[i][j].SetTileSolidity(false);
- m_tile[i][j].SetEntityTexture(NULL);
- m_tile[i][j].SetEntitySolidity(false);
- m_tile[i][j].SetMapTransitionName("null");
- }
- }
}
string Map::GetCurrentMap(void) {
return m_currentMap;
}
-bool Map::GetTileSolidity(int row, int column) {
- return m_tile[row + 1][column + 1].GetTileSolidity();
+bool Map::GetTileSolidity(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetTileSolidity();
}
-int Map::GetTileX(int row, int column) {
- return m_tile[row + 1][column + 1].GetTileX();
+int Map::GetTileX(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetTileX();
}
-int Map::GetTileY(int row, int column) {
- return m_tile[row + 1][column + 1].GetTileY();
+int Map::GetTileY(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetTileY();
}
-bool Map::GetEntitySolidity(int row, int column) {
- return m_tile[row + 1][column + 1].GetEntitySolitity();
+bool Map::GetEntitySolidity(int xArg, int yArg) {
+ if(xArg > x || yArg > y || yArg < 0 || yArg < 0) {
+ return false;
+ }
+
+ return m_tile[xArg + 1][yArg + 1].GetEntitySolitity();
}
-int Map::GetEntityX(int row, int column) {
- return m_tile[row + 1][column + 1].GetEntityX();
+int Map::GetEntityX(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetEntityX();
}
-int Map::GetEntityY(int row, int column) {
- return m_tile[row + 1][column + 1].GetEntityY();
+int Map::GetEntityY(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetEntityY();
}
-int Map::GetEntityWidth(int row, int column) {
- return m_tile[row + 1][column + 1].GetEntityWidth();
+int Map::GetEntityWidth(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetEntityWidth();
}
-int Map::GetEntityHeight(int row, int column) {
- return m_tile[row + 1][column + 1].GetEntityHeight();
+int Map::GetEntityHeight(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetEntityHeight();
}
-int Map::GetTileZLevel(int row, int column) {
- return m_tile[row + 1][column + 1].GetZLevel();
+int Map::GetTileZLevel(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetZLevel();
}
-string Map::GetMapTransitionName(int row, int column) {
- return m_tile[row + 1][column + 1].GetMapTransitionName();
+string Map::GetMapTransitionName(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetMapTransitionName();
}
-int Map::GetMapTransitionX(int row, int column) {
- return m_tile[row + 1][column + 1].GetMapTransitionX();
+int Map::GetMapTransitionX(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetMapTransitionX();
}
-int Map::GetMapTransitionY(int row, int column) {
- return m_tile[row + 1][column + 1].GetMapTransitionY();
+int Map::GetMapTransitionY(int xArg, int yArg) {
+ return m_tile[xArg + 1][yArg + 1].GetMapTransitionY();
}
diff --git a/src/libUnuk/Map.h b/src/libUnuk/Map.h
index b2ecc17..bd44b35 100644
--- a/src/libUnuk/Map.h
+++ b/src/libUnuk/Map.h
@@ -12,7 +12,6 @@
#include "../Unuk/Constants.h"
#include "ImageLoader.h"
#include "ApplySurface.h"
-#include "TextureManager.h"
#include "MapTile.h"
#include "Debug.h"
using namespace std;
@@ -27,21 +26,21 @@ public:
void Load(const string filename);
void Render(void);
- bool GetTileSolidity(int row, int column);
- int GetTileX(int row, int column);
- int GetTileY(int row, int column);
+ bool GetTileSolidity(int xArg, int yArg);
+ int GetTileX(int xArg, int yArg);
+ int GetTileY(int xArg, int yArg);
- bool GetEntitySolidity(int row, int column);
- int GetEntityX(int row, int column);
- int GetEntityY(int row, int column);
- int GetEntityWidth(int row, int column);
- int GetEntityHeight(int row, int column);
+ bool GetEntitySolidity(int xArg, int yArg);
+ int GetEntityX(int xArg, int yArg);
+ int GetEntityY(int xArg, int yArg);
+ int GetEntityWidth(int xArg, int yArg);
+ int GetEntityHeight(int xArg, int yArg);
- int GetTileZLevel(int row, int column);
+ int GetTileZLevel(int xArg, int yArg);
- string GetMapTransitionName(int row, int column);
- int GetMapTransitionX(int row, int column);
- int GetMapTransitionY(int row, int column);
+ string GetMapTransitionName(int xArg, int yArg);
+ int GetMapTransitionX(int xArg, int yArg);
+ int GetMapTransitionY(int xArg, int yArg);
string GetCurrentMap(void);
@@ -52,11 +51,11 @@ private:
int x;
int y;
- TextureManager m_tileTextures;
- TextureManager m_entityTextures;
-
static const int TILE_ARRAY_SIZE = 150;
MapTile m_tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE];
+
+ TextureManager m_tileTextures;
+ TextureManager m_entityTextures;
};
#endif
diff --git a/src/libUnuk/MapElement.cpp b/src/libUnuk/MapElement.cpp
new file mode 100644
index 0000000..6d5ec2f
--- /dev/null
+++ b/src/libUnuk/MapElement.cpp
@@ -0,0 +1,39 @@
+#include "MapElement.h"
+
+MapElement::MapElement(void) {
+
+}
+
+MapElement::~MapElement(void) {
+
+}
+
+void MapElement::SetTexture(SDL_Surface* arg) {
+ m_texture = arg;
+}
+
+void MapElement::Render(void) {
+ ApplySurface(x, y, m_texture, screen);
+}
+
+void MapElement::Update(void) {
+
+}
+
+void MapElement::SetSolidity(bool arg) {
+ m_solid = arg;
+}
+
+bool MapElement::GetSolidity(void) {
+ return m_solid;
+}
+
+void MapElement::SetXY(int xArg, int yArg) {
+ x = xArg,
+ y = yArg;
+}
+
+int MapElement::GetX(void) { return x; }
+int MapElement::GetY(void) { return y; }
+int MapElement::GetWidth(void) { return m_texture->w; }
+int MapElement::GetHeight(void) { return m_texture->h; }
diff --git a/src/libUnuk/MapElement.h b/src/libUnuk/MapElement.h
new file mode 100644
index 0000000..3960026
--- /dev/null
+++ b/src/libUnuk/MapElement.h
@@ -0,0 +1,39 @@
+#ifndef _MAPELEMENT_H_
+#define _MAPELEMENT_H_
+#include
+#include
+
+#include "../Unuk/Globals.h"
+#include "ApplySurface.h"
+#include "TextureManager.h"
+
+class MapElement {
+public:
+ MapElement(void);
+ ~MapElement(void);
+
+ static void SetTextureManager(TextureManager* arg);
+
+ virtual void SetTexture(SDL_Surface* arg);
+ virtual void Render(void);
+ virtual void Update(void);
+
+ void SetSolidity(bool arg);
+ bool GetSolidity(void);
+
+ void SetXY(int xArg, int yArg);
+ int GetX(void);
+ int GetY(void);
+ int GetWidth(void);
+ int GetHeight(void);
+
+protected:
+ SDL_Surface* m_texture;
+
+ bool m_solid;
+
+ int x;
+ int y;
+};
+
+#endif
diff --git a/src/libUnuk/MapEntities.cpp b/src/libUnuk/MapEntities.cpp
new file mode 100644
index 0000000..0c338f8
--- /dev/null
+++ b/src/libUnuk/MapEntities.cpp
@@ -0,0 +1,16 @@
+#include "MapEntities.h"
+
+MapEntityGeneric::MapEntityGeneric(void) {
+ m_texture = NULL;
+
+}
+
+MapEntityGeneric::~MapEntityGeneric(void) {
+
+}
+
+void MapEntityGeneric::Render(void) {
+ if(m_texture != NULL) {
+ MapElement::Render();
+ }
+}
diff --git a/src/libUnuk/MapEntities.h b/src/libUnuk/MapEntities.h
new file mode 100644
index 0000000..f84ad52
--- /dev/null
+++ b/src/libUnuk/MapEntities.h
@@ -0,0 +1,17 @@
+#ifndef _MAPENTITIES_H_
+#define _MAPENTITIES_H_
+
+#include "MapElement.h"
+
+class MapEntityGeneric : public MapElement {
+public:
+ MapEntityGeneric(void);
+ ~MapEntityGeneric(void);
+
+ void Render(void);
+
+private:
+
+};
+
+#endif
diff --git a/src/libUnuk/MapTile.h b/src/libUnuk/MapTile.h
index 08ca8cc..4c541e2 100644
--- a/src/libUnuk/MapTile.h
+++ b/src/libUnuk/MapTile.h
@@ -4,43 +4,44 @@
#include
#include
-#include "Entity.h"
+#include "../Unuk/Constants.h"
+#include "ApplySurface.h"
+#include "MapElement.h"
+#include "MapEntities.h"
using namespace std;
class MapTile {
public:
- MapTile(void) { m_entitySolidity = false; }
+ MapTile(void) { }
~MapTile(void) { }
- void SetTileTexture(SDL_Surface* surface) { m_tileTexture = surface; }
- SDL_Surface* GetTileTexture(void) { return m_tileTexture; }
+ void Render(void) { m_tile.Render(), m_entity.Render(); }
- void SetTileSolidity(bool arg) { m_tileSolidity = arg; }
- bool GetTileSolidity(void) { return m_tileSolidity; }
- void SetTileXY(int xArg, int yArg) { m_tileX = xArg, m_tileY = yArg; }
- int GetTileX(void) { return m_tileX; }
- int GetTileY(void) { return m_tileY; }
+ // Tile Mutators.
+ SDL_Surface SetTileTexture(SDL_Surface* arg) { m_tile.SetTexture(arg); }
+ void SetTileSolidity(bool arg) { m_tile.SetSolidity(arg); }
+ bool GetTileSolidity(void) { return m_tile.GetSolidity(); }
+ void SetTileXY(int xArg, int yArg) { m_tile.GetX(), m_tile.GetY(); }
+ int GetTileX(void) { return m_tile.GetX(); }
+ int GetTileY(void) { return m_tile.GetY(); }
- void SetEntityTexture(SDL_Surface* surface) {
- m_entityTexture = surface;
- if(m_entityTexture != NULL) {
- m_entityW = m_entityTexture->w;
- m_entityH = m_entityTexture->h;
- }
- }
- SDL_Surface* GetEntityTexture(void) { return m_entityTexture; }
- void SetEntitySolidity(bool arg) { m_entitySolidity = arg; }
- bool GetEntitySolitity(void) { return m_entitySolidity; }
- void SetEntityXY(int xArg, int yArg) { m_entityX = xArg, m_entityY = yArg; }
- int GetEntityX(void) { return m_entityX; }
- int GetEntityY(void) { return m_entityY; }
+ // Entity Mutators.
+ void SetEntityTexture(SDL_Surface* arg) { m_entity.SetTexture(arg); }
+ void SetEntityXY(int xArg, int yArg) { m_entity.SetXY(xArg, yArg); }
+ void SetEntitySolidity(bool arg) { m_entity.SetSolidity(arg); }
+ bool GetEntitySolitity(void) { return m_entity.GetSolidity(); }
- int GetEntityWidth(void) { return m_entityW; }
- int GetEntityHeight(void) { return m_entityH; }
+ // Entity Mutators.
+ int GetEntityX(void) { return m_entity.GetX(); }
+ int GetEntityY(void) { return m_entity.GetY(); }
+ int GetEntityWidth(void) { return m_entity.GetWidth(); }
+ int GetEntityHeight(void) { return m_entity.GetHeight(); }
+ // ZLevel Mutators.
void SetZLevel(int arg) { m_zLevel = arg; }
int GetZLevel(void) { return m_zLevel; }
+ // Map Transition Mutators.
void SetMapTransitionName(string arg) { m_mapTransitionName = arg; }
string GetMapTransitionName(void) { return m_mapTransitionName; }
@@ -49,17 +50,8 @@ public:
int GetMapTransitionY(void) { return m_mapTransitionY; }
private:
- SDL_Surface* m_entityTexture;
- bool m_tileSolidity;
- int m_tileX;
- int m_tileY;
-
- SDL_Surface* m_tileTexture;
- bool m_entitySolidity;
- int m_entityX;
- int m_entityY;
- int m_entityW;
- int m_entityH;
+ MapElement m_tile;
+ MapEntityGeneric m_entity;
// -1 is a 'special' tile, the next tile that the player walks
// on is the players new zlevel.