[Fix] Saveing from a none collision area so I can bleeding move....
This commit is contained in:
parent
5c2330c16b
commit
b94cfb69fa
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
<save>
|
<save>
|
||||||
<name>Allanis</name>
|
<name>Allanis</name>
|
||||||
<x>120</x>
|
<x>736</x>
|
||||||
<y>180</y>
|
<y>20</y>
|
||||||
<map>map</map>
|
<map>map</map>
|
||||||
</save>
|
</save>
|
||||||
|
139
Unuk-QT/Makefile
139
Unuk-QT/Makefile
@ -1,25 +1,25 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
# Makefile for building: Unuk-QT
|
# Makefile for building: Unuk-QT
|
||||||
# Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Feb 1 19:59:14 2012
|
# Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Feb 1 18:06:22 2012
|
||||||
# Project: Unuk-QT.pro
|
# Project: Unuk-QT.pro
|
||||||
# Template: app
|
# Template: app
|
||||||
# Command: /home/kono/QtSDK/Desktop/Qt/474/gcc/bin/qmake -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
# Command: /usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
####### Compiler, tools and options
|
####### Compiler, tools and options
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB
|
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
|
||||||
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
||||||
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
|
||||||
INCPATH = -I../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ -I. -I../../../QtSDK/Desktop/Qt/474/gcc/include/QtCore -I../../../QtSDK/Desktop/Qt/474/gcc/include/QtGui -I../../../QtSDK/Desktop/Qt/474/gcc/include -I.
|
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
|
||||||
LINK = g++
|
LINK = g++
|
||||||
LFLAGS = -Wl,-rpath,/home/kono/QtSDK/Desktop/Qt/474/gcc/lib
|
LFLAGS =
|
||||||
LIBS = $(SUBLIBS) -L/home/kono/QtSDK/Desktop/Qt/474/gcc/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lSDL_gfx -ltinyxml -lGLU -lQtGui -lQtCore -lpthread
|
LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lSDL_gfx -ltinyxml -lGLU -lQtGui -lQtCore -lpthread
|
||||||
AR = ar cqs
|
AR = ar cqs
|
||||||
RANLIB =
|
RANLIB =
|
||||||
QMAKE = /home/kono/QtSDK/Desktop/Qt/474/gcc/bin/qmake
|
QMAKE = /usr/bin/qmake-qt4
|
||||||
TAR = tar -cf
|
TAR = tar -cf
|
||||||
COMPRESS = gzip -9f
|
COMPRESS = gzip -9f
|
||||||
COPY = cp -f
|
COPY = cp -f
|
||||||
@ -109,26 +109,25 @@ OBJECTS = WorldManager.o \
|
|||||||
EventHistory.o \
|
EventHistory.o \
|
||||||
Bar.o \
|
Bar.o \
|
||||||
Vec2.o
|
Vec2.o
|
||||||
DIST = ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/g++.conf \
|
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf \
|
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf \
|
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri \
|
/usr/share/qt4/mkspecs/qconfig.pri \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri \
|
/usr/share/qt4/mkspecs/features/qt_functions.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf \
|
/usr/share/qt4/mkspecs/features/qt_config.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf \
|
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf \
|
/usr/share/qt4/mkspecs/features/default_pre.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf \
|
/usr/share/qt4/mkspecs/features/debug.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf \
|
/usr/share/qt4/mkspecs/features/default_post.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf \
|
/usr/share/qt4/mkspecs/features/warn_on.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf \
|
/usr/share/qt4/mkspecs/features/qt.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf \
|
/usr/share/qt4/mkspecs/features/unix/thread.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf \
|
/usr/share/qt4/mkspecs/features/moc.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf \
|
/usr/share/qt4/mkspecs/features/resources.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf \
|
/usr/share/qt4/mkspecs/features/uic.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf \
|
/usr/share/qt4/mkspecs/features/yacc.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf \
|
/usr/share/qt4/mkspecs/features/lex.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf \
|
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf \
|
|
||||||
Unuk-QT.pro
|
Unuk-QT.pro
|
||||||
QMAKE_TARGET = Unuk-QT
|
QMAKE_TARGET = Unuk-QT
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
@ -161,49 +160,51 @@ all: Makefile $(TARGET)
|
|||||||
$(TARGET): $(OBJECTS)
|
$(TARGET): $(OBJECTS)
|
||||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
|
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
|
||||||
|
|
||||||
Makefile: Unuk-QT.pro ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++/qmake.conf ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/g++.conf \
|
Makefile: Unuk-QT.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf \
|
/usr/share/qt4/mkspecs/common/unix.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf \
|
/usr/share/qt4/mkspecs/common/linux.conf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri \
|
/usr/share/qt4/mkspecs/qconfig.pri \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri \
|
/usr/share/qt4/mkspecs/features/qt_functions.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf \
|
/usr/share/qt4/mkspecs/features/qt_config.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf \
|
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf \
|
/usr/share/qt4/mkspecs/features/default_pre.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf \
|
/usr/share/qt4/mkspecs/features/debug.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf \
|
/usr/share/qt4/mkspecs/features/default_post.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf \
|
/usr/share/qt4/mkspecs/features/warn_on.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf \
|
/usr/share/qt4/mkspecs/features/qt.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf \
|
/usr/share/qt4/mkspecs/features/unix/thread.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf \
|
/usr/share/qt4/mkspecs/features/moc.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf \
|
/usr/share/qt4/mkspecs/features/resources.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf \
|
/usr/share/qt4/mkspecs/features/uic.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf \
|
/usr/share/qt4/mkspecs/features/yacc.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf \
|
/usr/share/qt4/mkspecs/features/lex.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf \
|
/usr/share/qt4/mkspecs/features/include_source_dir.prf \
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf
|
/usr/lib/libQtGui.prl \
|
||||||
$(QMAKE) -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
/usr/lib/libQtCore.prl
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/g++.conf:
|
$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf:
|
/usr/share/qt4/mkspecs/common/g++.conf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf:
|
/usr/share/qt4/mkspecs/common/unix.conf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri:
|
/usr/share/qt4/mkspecs/common/linux.conf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri:
|
/usr/share/qt4/mkspecs/qconfig.pri:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf:
|
/usr/share/qt4/mkspecs/features/qt_functions.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf:
|
/usr/share/qt4/mkspecs/features/qt_config.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf:
|
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf:
|
/usr/share/qt4/mkspecs/features/default_pre.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf:
|
/usr/share/qt4/mkspecs/features/debug.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf:
|
/usr/share/qt4/mkspecs/features/default_post.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf:
|
/usr/share/qt4/mkspecs/features/warn_on.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf:
|
/usr/share/qt4/mkspecs/features/qt.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf:
|
/usr/share/qt4/mkspecs/features/unix/thread.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf:
|
/usr/share/qt4/mkspecs/features/moc.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf:
|
/usr/share/qt4/mkspecs/features/resources.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf:
|
/usr/share/qt4/mkspecs/features/uic.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf:
|
/usr/share/qt4/mkspecs/features/yacc.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf:
|
/usr/share/qt4/mkspecs/features/lex.prf:
|
||||||
../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf:
|
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
|
||||||
|
/usr/lib/libQtGui.prl:
|
||||||
|
/usr/lib/libQtCore.prl:
|
||||||
qmake: FORCE
|
qmake: FORCE
|
||||||
@$(QMAKE) -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
@$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
@$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0
|
||||||
|
@ -47,21 +47,21 @@ public:
|
|||||||
|
|
||||||
void OnAttack(void);
|
void OnAttack(void);
|
||||||
|
|
||||||
// inline void* operator new(size_t size) {
|
// inline void* operator new(size_t size) {
|
||||||
// return gMemManager.Allocate(size);
|
// return gMemManager.Allocate(size);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// inline void operator delete(void* object) {
|
// inline void operator delete(void* object) {
|
||||||
// gMemManager.Free(object);
|
// gMemManager.Free(object);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// inline void* operator new [](size_t size) {
|
// inline void* operator new [](size_t size) {
|
||||||
// return gMemManager.Allocate(size);
|
// return gMemManager.Allocate(size);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// inline void operator delete [](void* object) {
|
// inline void operator delete [](void* object) {
|
||||||
// gMemManager.Free(object);
|
// gMemManager.Free(object);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static const int FACING_UP = 0;
|
static const int FACING_UP = 0;
|
||||||
static const int FACING_RIGHT = 1;
|
static const int FACING_RIGHT = 1;
|
||||||
|
@ -10,328 +10,328 @@ LevelGen::~LevelGen(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::Load(const string filename) {
|
void LevelGen::Load(const string filename) {
|
||||||
Unload();
|
Unload();
|
||||||
_currentMap = filename;
|
_currentMap = filename;
|
||||||
string fullMapPath = "../Data/Media/Maps/" + filename;
|
string fullMapPath = "../Data/Media/Maps/" + filename;
|
||||||
TiXmlDocument mapFile(fullMapPath.c_str());
|
TiXmlDocument mapFile(fullMapPath.c_str());
|
||||||
|
|
||||||
assert(mapFile.LoadFile() == true);
|
assert(mapFile.LoadFile() == true);
|
||||||
|
|
||||||
// Getting dirty with some XML. This seems like a nicer
|
// Getting dirty with some XML. This seems like a nicer
|
||||||
// approach to loading maps, rather than parsing text files.
|
// approach to loading maps, rather than parsing text files.
|
||||||
TiXmlElement* rootElem = NULL;
|
TiXmlElement* rootElem = NULL;
|
||||||
TiXmlElement* lineElem = NULL;
|
TiXmlElement* lineElem = NULL;
|
||||||
TiXmlElement* tileElem = NULL;
|
TiXmlElement* tileElem = NULL;
|
||||||
TiXmlElement* dataElem = NULL;
|
TiXmlElement* dataElem = NULL;
|
||||||
|
|
||||||
x = -1;
|
x = -1;
|
||||||
y = -1;
|
y = -1;
|
||||||
|
|
||||||
// <map> - Let's start parsing the map.
|
// <map> - Let's start parsing the map.
|
||||||
rootElem = mapFile.FirstChildElement("map");
|
rootElem = mapFile.FirstChildElement("map");
|
||||||
assert(rootElem != NULL);
|
assert(rootElem != NULL);
|
||||||
if(rootElem) {
|
if(rootElem) {
|
||||||
// <line> - We want to tile one line at a time. line represents
|
// <line> - We want to tile one line at a time. line represents
|
||||||
// the row we are tiling.
|
// the row we are tiling.
|
||||||
lineElem = rootElem->FirstChildElement("line");
|
lineElem = rootElem->FirstChildElement("line");
|
||||||
assert(lineElem != NULL);
|
assert(lineElem != NULL);
|
||||||
while(lineElem) {
|
while(lineElem) {
|
||||||
y++;
|
y++;
|
||||||
x = -1;
|
x = -1;
|
||||||
|
|
||||||
// <tile> - Then we will select the tile. and increment x to keep tiling that row.
|
// <tile> - Then we will select the tile. and increment x to keep tiling that row.
|
||||||
tileElem = lineElem->FirstChildElement("tile");
|
tileElem = lineElem->FirstChildElement("tile");
|
||||||
assert(tileElem != NULL);
|
assert(tileElem != NULL);
|
||||||
while(tileElem) {
|
while(tileElem) {
|
||||||
x++;
|
x++;
|
||||||
_tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT);
|
_tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT);
|
||||||
|
|
||||||
// <tileTexture> - Apply a teture to the tile.
|
// <tileTexture> - Apply a teture to the tile.
|
||||||
dataElem = tileElem->FirstChildElement("tileTexture");
|
dataElem = tileElem->FirstChildElement("tileTexture");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
stringstream tilePath;
|
stringstream tilePath;
|
||||||
tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png";
|
tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png";
|
||||||
_tile[x][y].SetTileTexture(_tileTextures.Add(tilePath.str()));
|
_tile[x][y].SetTileTexture(_tileTextures.Add(tilePath.str()));
|
||||||
// <tileTexture> - Finished applying the texture, move to the next sibling.
|
// <tileTexture> - Finished applying the texture, move to the next sibling.
|
||||||
|
|
||||||
// <solidTile> - Check to see if the tile is solid or not.
|
// <solidTile> - Check to see if the tile is solid or not.
|
||||||
dataElem = dataElem->NextSiblingElement("solidTile");
|
dataElem = dataElem->NextSiblingElement("solidTile");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
string tileSolidity = dataElem->GetText();
|
string tileSolidity = dataElem->GetText();
|
||||||
assert(tileSolidity == "false" || tileSolidity == "true");
|
assert(tileSolidity == "false" || tileSolidity == "true");
|
||||||
if(tileSolidity == "false")
|
if(tileSolidity == "false")
|
||||||
_tile[x][y].SetTileSolidity(false);
|
_tile[x][y].SetTileSolidity(false);
|
||||||
else
|
else
|
||||||
_tile[x][y].SetTileSolidity(true);
|
_tile[x][y].SetTileSolidity(true);
|
||||||
// </solidTile>
|
// </solidTile>
|
||||||
|
|
||||||
// <entityTexture>
|
// <entityTexture>
|
||||||
dataElem = dataElem->NextSiblingElement("entityTexture");
|
dataElem = dataElem->NextSiblingElement("entityTexture");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
string entityName = dataElem->GetText();
|
string entityName = dataElem->GetText();
|
||||||
if(entityName != "null") {
|
if(entityName != "null") {
|
||||||
stringstream entityPath;
|
stringstream entityPath;
|
||||||
entityPath << "../Data/Media/Images/Entities/" << entityName << ".png";
|
entityPath << "../Data/Media/Images/Entities/" << entityName << ".png";
|
||||||
_tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(entityPath.str()));
|
_tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(entityPath.str()));
|
||||||
|
|
||||||
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
|
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
|
||||||
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
|
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
|
||||||
}
|
}
|
||||||
// </entityTexture>
|
// </entityTexture>
|
||||||
|
|
||||||
// <SolidEntity>
|
// <SolidEntity>
|
||||||
dataElem = dataElem->NextSiblingElement("solidEntity");
|
dataElem = dataElem->NextSiblingElement("solidEntity");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
string entitySolidity = dataElem->GetText();
|
string entitySolidity = dataElem->GetText();
|
||||||
assert(entitySolidity == "false" || entitySolidity == "true");
|
assert(entitySolidity == "false" || entitySolidity == "true");
|
||||||
if(entitySolidity == "false")
|
if(entitySolidity == "false")
|
||||||
_tile[x][y].SetEntitySolidity(false);
|
_tile[x][y].SetEntitySolidity(false);
|
||||||
else
|
else
|
||||||
_tile[x][y].SetEntitySolidity(true);
|
_tile[x][y].SetEntitySolidity(true);
|
||||||
// </solidEntity>
|
// </solidEntity>
|
||||||
|
|
||||||
// <zlevel>
|
// <zlevel>
|
||||||
dataElem = dataElem->NextSiblingElement("zLevel");
|
dataElem = dataElem->NextSiblingElement("zLevel");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
_tile[x][y].SetZLevel(atoi(dataElem->GetText()));
|
_tile[x][y].SetZLevel(atoi(dataElem->GetText()));
|
||||||
// </zlevel>
|
// </zlevel>
|
||||||
|
|
||||||
// <mapTransition>
|
// <mapTransition>
|
||||||
dataElem = dataElem->NextSiblingElement("mapTransition");
|
dataElem = dataElem->NextSiblingElement("mapTransition");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
_tile[x][y].SetMapTransitionName(dataElem->GetText());
|
_tile[x][y].SetMapTransitionName(dataElem->GetText());
|
||||||
// </mapTransition>
|
// </mapTransition>
|
||||||
|
|
||||||
// <mapTransX>
|
// <mapTransX>
|
||||||
dataElem = dataElem->NextSiblingElement("mapTransX");
|
dataElem = dataElem->NextSiblingElement("mapTransX");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
// int mapTransX = atoi(dataElem->GetText()); // not referenced
|
// int mapTransX = atoi(dataElem->GetText()); // not referenced
|
||||||
// </mapTransX>
|
// </mapTransX>
|
||||||
|
|
||||||
// <mapTransY>
|
// <mapTransY>
|
||||||
dataElem = dataElem->NextSiblingElement("mapTransY");
|
dataElem = dataElem->NextSiblingElement("mapTransY");
|
||||||
assert(dataElem != NULL);
|
assert(dataElem != NULL);
|
||||||
// int mapTransY = atoi(dataElem->GetText()); // not referenced
|
// int mapTransY = atoi(dataElem->GetText()); // not referenced
|
||||||
// </mapTransY>
|
// </mapTransY>
|
||||||
|
|
||||||
tileElem = tileElem->NextSiblingElement("tile");
|
tileElem = tileElem->NextSiblingElement("tile");
|
||||||
}
|
}
|
||||||
//</tile>
|
//</tile>
|
||||||
|
|
||||||
lineElem = lineElem->NextSiblingElement("line");
|
lineElem = lineElem->NextSiblingElement("line");
|
||||||
}
|
}
|
||||||
// </line>
|
// </line>
|
||||||
}
|
}
|
||||||
// </map>
|
// </map>
|
||||||
levelWidth = x * TILE_WIDTH;
|
levelWidth = x * TILE_WIDTH;
|
||||||
levelHeight = y * TILE_HEIGHT;
|
levelHeight = y * TILE_HEIGHT;
|
||||||
|
|
||||||
// procedural generation
|
// procedural generation
|
||||||
DoMagic();
|
DoMagic();
|
||||||
|
|
||||||
//character->Load(filename);
|
//character->Load(filename);
|
||||||
|
|
||||||
NPC* npc = new NPC(this);
|
NPC* npc = new NPC(this);
|
||||||
|
|
||||||
int spawnX;
|
int spawnX;
|
||||||
int spawnY;
|
int spawnY;
|
||||||
|
|
||||||
//FindSpawnPoint(spawnX, spawnY);
|
//FindSpawnPoint(spawnX, spawnY);
|
||||||
//npc->SetXY(spawnX, spawnY); // try to uncomment this, try to find out what's going on.. --konom
|
//npc->SetXY(spawnX, spawnY); // try to uncomment this, try to find out what's going on.. --konom
|
||||||
npc->SetXY(100, 230);
|
npc->SetXY(100, 230);
|
||||||
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||||
_world.AddNPC(npc);
|
_world.AddNPC(npc);
|
||||||
|
|
||||||
npc = new NPC(this);
|
npc = new NPC(this);
|
||||||
//FindSpawnPoint(spawnX, spawnY);
|
//FindSpawnPoint(spawnX, spawnY);
|
||||||
npc->SetXY(300, 250);
|
npc->SetXY(300, 250);
|
||||||
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||||
_world.AddNPC(npc);
|
_world.AddNPC(npc);
|
||||||
|
|
||||||
npc = new NPC(this);
|
npc = new NPC(this);
|
||||||
//FindSpawnPoint(spawnX, spawnY);
|
//FindSpawnPoint(spawnX, spawnY);
|
||||||
npc->SetXY(400, 100);
|
npc->SetXY(400, 100);
|
||||||
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||||
_world.AddNPC(npc);
|
_world.AddNPC(npc);
|
||||||
|
|
||||||
npc = new NPC(this);
|
npc = new NPC(this);
|
||||||
//FindSpawnPoint(spawnX, spawnY);
|
//FindSpawnPoint(spawnX, spawnY);
|
||||||
npc->SetXY(200, 400);
|
npc->SetXY(200, 400);
|
||||||
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||||
_world.AddNPC(npc);
|
_world.AddNPC(npc);
|
||||||
|
|
||||||
npc = new NPC(this);
|
npc = new NPC(this);
|
||||||
//FindSpawnPoint(spawnX, spawnY);
|
//FindSpawnPoint(spawnX, spawnY);
|
||||||
npc->SetXY(250, 250);
|
npc->SetXY(250, 250);
|
||||||
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45);
|
||||||
_world.AddNPC(npc);
|
_world.AddNPC(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::Update(void) {
|
void LevelGen::Update(void) {
|
||||||
_world.Update();
|
_world.Update();
|
||||||
// Update the map so we can render when camera moves.
|
// Update the map so we can render when camera moves.
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::Render(void) {
|
void LevelGen::Render(void) {
|
||||||
int xOrig = (camera.x / TILE_WIDTH) - 1;
|
int xOrig = (camera.x / TILE_WIDTH) - 1;
|
||||||
int yOrig = (camera.y / TILE_HEIGHT) - 1;
|
int yOrig = (camera.y / TILE_HEIGHT) - 1;
|
||||||
|
|
||||||
if (xOrig < 0) xOrig = 0;
|
if (xOrig < 0) xOrig = 0;
|
||||||
if (yOrig < 0) yOrig = 0;
|
if (yOrig < 0) yOrig = 0;
|
||||||
|
|
||||||
int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH) + 3;
|
int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH) + 3;
|
||||||
int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT) + 3;
|
int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT) + 3;
|
||||||
|
|
||||||
/* the fuck is this Allanis? --konom
|
/* the fuck is this Allanis? --konom
|
||||||
if(xEnd < x)
|
if(xEnd < x)
|
||||||
xEnd++;
|
xEnd++;
|
||||||
else
|
else
|
||||||
xEnd = x;
|
xEnd = x;
|
||||||
|
|
||||||
if(yEnd < y)
|
if(yEnd < y)
|
||||||
yEnd++;
|
yEnd++;
|
||||||
else
|
else
|
||||||
yEnd = y;
|
yEnd = y;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (xEnd > x) xEnd = x;
|
if (xEnd > x) xEnd = x;
|
||||||
if (yEnd > y) yEnd = y;
|
if (yEnd > y) yEnd = y;
|
||||||
if (xEnd < 0) xEnd = 0;
|
if (xEnd < 0) xEnd = 0;
|
||||||
if (yEnd < 0) yEnd = 0;
|
if (yEnd < 0) yEnd = 0;
|
||||||
|
|
||||||
if (xOrig > xEnd) xOrig = xEnd - 1;
|
if (xOrig > xEnd) xOrig = xEnd - 1;
|
||||||
if (yOrig > yEnd) yOrig = yEnd - 1;
|
if (yOrig > yEnd) yOrig = yEnd - 1;
|
||||||
|
|
||||||
for(int i = xOrig; i < xEnd; i++) {
|
for(int i = xOrig; i < xEnd; i++) {
|
||||||
for(int j = yOrig; j < yEnd; j++) {
|
for(int j = yOrig; j < yEnd; j++) {
|
||||||
_tile[i][j].Render();
|
_tile[i][j].Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_world.Render();
|
_world.Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::Unload(void) {
|
void LevelGen::Unload(void) {
|
||||||
_tileTextures.Unload();
|
_tileTextures.Unload();
|
||||||
_entityTextures.Unload();
|
_entityTextures.Unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::DoMagic(void) {
|
void LevelGen::DoMagic(void) {
|
||||||
GenerateEntities("tree", 25);
|
GenerateEntities("tree", 25);
|
||||||
GenerateEntities("hedge", 15);
|
GenerateEntities("hedge", 15);
|
||||||
GenerateEntities("barrel", 40);
|
GenerateEntities("barrel", 40);
|
||||||
MakeWalkingPaths();
|
MakeWalkingPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::GenerateEntities(const string& name, int frequency) {
|
void LevelGen::GenerateEntities(const string& name, int frequency) {
|
||||||
int nextEntityGen = 1 + (rand() % frequency);
|
int nextEntityGen = 1 + (rand() % frequency);
|
||||||
std::string filename = "../Data/Media/Images/Entities/" + name + ".png";
|
std::string filename = "../Data/Media/Images/Entities/" + name + ".png";
|
||||||
|
|
||||||
for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) {
|
for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) {
|
||||||
for(int y = 0; y < SCREEN_HEIGHT/64; y++) {
|
for(int y = 0; y < SCREEN_HEIGHT/64; y++) {
|
||||||
nextEntityGen--;
|
nextEntityGen--;
|
||||||
if(!_tile[x][y].GetTileSolidity() && !_tile[x][y].GetEntitySolitity() && nextEntityGen <= 0) {
|
if(!_tile[x][y].GetTileSolidity() && !_tile[x][y].GetEntitySolitity() && nextEntityGen <= 0) {
|
||||||
_tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(filename));
|
_tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(filename));
|
||||||
|
|
||||||
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
|
_tile[x][y].SetEntityXY(_tile[x][y].GetTileX() + TILE_WIDTH / 2 - _tile[x][y].GetEntityWidth() / 2,
|
||||||
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
|
_tile[x][y].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2);
|
||||||
|
|
||||||
_tile[x][y].SetEntitySolidity(true);
|
_tile[x][y].SetEntitySolidity(true);
|
||||||
|
|
||||||
nextEntityGen = 1 + (rand() % frequency);
|
nextEntityGen = 1 + (rand() % frequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::MakeWalkingPaths(void) {
|
void LevelGen::MakeWalkingPaths(void) {
|
||||||
int lastOpenY = rand() % 5;
|
int lastOpenY = rand() % 5;
|
||||||
|
|
||||||
for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) {
|
for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) {
|
||||||
bool pathFound = false;
|
bool pathFound = false;
|
||||||
|
|
||||||
for(int y = 0; y < SCREEN_HEIGHT/64; y++) {
|
for(int y = 0; y < SCREEN_HEIGHT/64; y++) {
|
||||||
if(!_tile[x][y].GetEntitySolitity()) {
|
if(!_tile[x][y].GetEntitySolitity()) {
|
||||||
pathFound = true;
|
pathFound = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
lastOpenY = y;
|
lastOpenY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pathFound) {
|
if(!pathFound) {
|
||||||
_tile[x][lastOpenY].SetEntityTexture(NULL);
|
_tile[x][lastOpenY].SetEntityTexture(NULL);
|
||||||
_tile[x][lastOpenY].SetEntitySolidity(false);
|
_tile[x][lastOpenY].SetEntitySolidity(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelGen::FindSpawnPoint(int& xArg, int& yArg) {
|
void LevelGen::FindSpawnPoint(int& xArg, int& yArg) {
|
||||||
xArg = rand() % SCREEN_WIDTH;
|
xArg = rand() % SCREEN_WIDTH;
|
||||||
yArg = rand() % SCREEN_HEIGHT;
|
yArg = rand() % SCREEN_HEIGHT;
|
||||||
|
|
||||||
int tileX = xArg / 64;
|
int tileX = xArg / 64;
|
||||||
int tileY = yArg / 64;
|
int tileY = yArg / 64;
|
||||||
|
|
||||||
if(!_tile[tileX][tileY].GetEntitySolitity() && !_world.HasNPCIn(xArg, yArg)) {
|
if(!_tile[tileX][tileY].GetEntitySolitity() && !_world.HasNPCIn(xArg, yArg)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FindSpawnPoint(xArg, yArg);
|
FindSpawnPoint(xArg, yArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
string LevelGen::GetCurrentMap(void) {
|
string LevelGen::GetCurrentMap(void) {
|
||||||
return _currentMap;
|
return _currentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LevelGen::GetTileSolidity(int xArg, int yArg) {
|
bool LevelGen::GetTileSolidity(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetTileSolidity();
|
return _tile[xArg + 1][yArg + 1].GetTileSolidity();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetTileX(int xArg, int yArg) {
|
int LevelGen::GetTileX(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetTileX();
|
return _tile[xArg + 1][yArg + 1].GetTileX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetTileY(int xArg, int yArg) {
|
int LevelGen::GetTileY(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetTileY();
|
return _tile[xArg + 1][yArg + 1].GetTileY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LevelGen::GetEntitySolidity(int xArg, int yArg) {
|
bool LevelGen::GetEntitySolidity(int xArg, int yArg) {
|
||||||
if(xArg > x || yArg > y || yArg < 0 || yArg < 0) {
|
if(xArg > x || yArg > y || yArg < 0 || yArg < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _tile[xArg + 1][yArg + 1].GetEntitySolitity();
|
return _tile[xArg + 1][yArg + 1].GetEntitySolitity();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetEntityX(int xArg, int yArg) {
|
int LevelGen::GetEntityX(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetEntityX();
|
return _tile[xArg + 1][yArg + 1].GetEntityX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetEntityY(int xArg, int yArg) {
|
int LevelGen::GetEntityY(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetEntityY();
|
return _tile[xArg + 1][yArg + 1].GetEntityY();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetEntityWidth(int xArg, int yArg) {
|
int LevelGen::GetEntityWidth(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetEntityWidth();
|
return _tile[xArg + 1][yArg + 1].GetEntityWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetEntityHeight(int xArg, int yArg) {
|
int LevelGen::GetEntityHeight(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetEntityHeight();
|
return _tile[xArg + 1][yArg + 1].GetEntityHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetTileZLevel(int xArg, int yArg) {
|
int LevelGen::GetTileZLevel(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetZLevel();
|
return _tile[xArg + 1][yArg + 1].GetZLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
string LevelGen::GetMapTransitionName(int xArg, int yArg) {
|
string LevelGen::GetMapTransitionName(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetMapTransitionName();
|
return _tile[xArg + 1][yArg + 1].GetMapTransitionName();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetMapTransitionX(int xArg, int yArg) {
|
int LevelGen::GetMapTransitionX(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetMapTransitionX();
|
return _tile[xArg + 1][yArg + 1].GetMapTransitionX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelGen::GetMapTransitionY(int xArg, int yArg) {
|
int LevelGen::GetMapTransitionY(int xArg, int yArg) {
|
||||||
return _tile[xArg + 1][yArg + 1].GetMapTransitionY();
|
return _tile[xArg + 1][yArg + 1].GetMapTransitionY();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user