From b94cfb69fa84864a3926e64612ef4c8368e766bd Mon Sep 17 00:00:00 2001 From: Rtch90 Date: Wed, 1 Feb 2012 18:42:24 +0000 Subject: [PATCH] [Fix] Saveing from a none collision area so I can bleeding move.... --- Save/save | 4 +- Unuk-QT/Makefile | 139 ++++----- src/libUnuk/Engine/Character.h | 24 +- src/libUnuk/LevelGen/LevelGen.cpp | 464 +++++++++++++++--------------- 4 files changed, 316 insertions(+), 315 deletions(-) diff --git a/Save/save b/Save/save index f7492c8..c5e2b63 100644 --- a/Save/save +++ b/Save/save @@ -1,7 +1,7 @@ Allanis - 120 - 180 + 736 + 20 map diff --git a/Unuk-QT/Makefile b/Unuk-QT/Makefile index dbe43f2..440db88 100644 --- a/Unuk-QT/Makefile +++ b/Unuk-QT/Makefile @@ -1,25 +1,25 @@ ############################################################################# # 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 # 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 CC = gcc 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) 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++ -LFLAGS = -Wl,-rpath,/home/kono/QtSDK/Desktop/Qt/474/gcc/lib -LIBS = $(SUBLIBS) -L/home/kono/QtSDK/Desktop/Qt/474/gcc/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lSDL_gfx -ltinyxml -lGLU -lQtGui -lQtCore -lpthread +LFLAGS = +LIBS = $(SUBLIBS) -L/usr/lib -lGL -lSDL -lSDL_ttf -lSDL_image -lSDL_gfx -ltinyxml -lGLU -lQtGui -lQtCore -lpthread AR = ar cqs RANLIB = -QMAKE = /home/kono/QtSDK/Desktop/Qt/474/gcc/bin/qmake +QMAKE = /usr/bin/qmake-qt4 TAR = tar -cf COMPRESS = gzip -9f COPY = cp -f @@ -109,26 +109,25 @@ OBJECTS = WorldManager.o \ EventHistory.o \ Bar.o \ Vec2.o -DIST = ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/g++.conf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf \ +DIST = /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ Unuk-QT.pro QMAKE_TARGET = Unuk-QT DESTDIR = @@ -161,49 +160,51 @@ all: Makefile $(TARGET) $(TARGET): $(OBJECTS) $(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 \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf \ - ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf - $(QMAKE) -spec ../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/g++.conf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/unix.conf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/common/linux.conf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/qconfig.pri: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/modules/qt_webkit_version.pri: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_functions.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt_config.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/exclusive_builds.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_pre.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/debug.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/default_post.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/warn_on.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/qt.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/unix/thread.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/moc.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/resources.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/uic.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/yacc.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/lex.prf: -../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/features/include_source_dir.prf: +Makefile: Unuk-QT.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \ + /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/debug.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/libQtGui.prl \ + /usr/lib/libQtCore.prl + $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile Unuk-QT.pro +/usr/share/qt4/mkspecs/common/g++.conf: +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/debug.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/libQtGui.prl: +/usr/lib/libQtCore.prl: 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: @$(CHK_DIR_EXISTS) .tmp/Unuk-QT1.0.0 || $(MKDIR) .tmp/Unuk-QT1.0.0 diff --git a/src/libUnuk/Engine/Character.h b/src/libUnuk/Engine/Character.h index 232cdb0..275e1c7 100644 --- a/src/libUnuk/Engine/Character.h +++ b/src/libUnuk/Engine/Character.h @@ -47,21 +47,21 @@ public: void OnAttack(void); -// inline void* operator new(size_t size) { -// return gMemManager.Allocate(size); -// } +// inline void* operator new(size_t size) { +// return gMemManager.Allocate(size); +// } // -// inline void operator delete(void* object) { -// gMemManager.Free(object); -// } +// inline void operator delete(void* object) { +// gMemManager.Free(object); +// } // -// inline void* operator new [](size_t size) { -// return gMemManager.Allocate(size); -// } +// inline void* operator new [](size_t size) { +// return gMemManager.Allocate(size); +// } // -// inline void operator delete [](void* object) { -// gMemManager.Free(object); -// } +// inline void operator delete [](void* object) { +// gMemManager.Free(object); +// } static const int FACING_UP = 0; static const int FACING_RIGHT = 1; diff --git a/src/libUnuk/LevelGen/LevelGen.cpp b/src/libUnuk/LevelGen/LevelGen.cpp index 00d8e37..aff5392 100644 --- a/src/libUnuk/LevelGen/LevelGen.cpp +++ b/src/libUnuk/LevelGen/LevelGen.cpp @@ -10,328 +10,328 @@ LevelGen::~LevelGen(void) { } void LevelGen::Load(const string filename) { - Unload(); - _currentMap = filename; - string fullMapPath = "../Data/Media/Maps/" + filename; - TiXmlDocument mapFile(fullMapPath.c_str()); + Unload(); + _currentMap = filename; + string fullMapPath = "../Data/Media/Maps/" + filename; + 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. - TiXmlElement* rootElem = NULL; - TiXmlElement* lineElem = NULL; - TiXmlElement* tileElem = NULL; - TiXmlElement* dataElem = NULL; + TiXmlElement* rootElem = NULL; + TiXmlElement* lineElem = NULL; + TiXmlElement* tileElem = NULL; + TiXmlElement* dataElem = NULL; - x = -1; - y = -1; + x = -1; + y = -1; - // - Let's start parsing the map. - rootElem = mapFile.FirstChildElement("map"); - assert(rootElem != NULL); - if(rootElem) { - // - We want to tile one line at a time. line represents - // the row we are tiling. - lineElem = rootElem->FirstChildElement("line"); - assert(lineElem != NULL); - while(lineElem) { - y++; - x = -1; + // - Let's start parsing the map. + rootElem = mapFile.FirstChildElement("map"); + assert(rootElem != NULL); + if(rootElem) { + // - We want to tile one line at a time. line represents + // the row we are tiling. + lineElem = rootElem->FirstChildElement("line"); + assert(lineElem != NULL); + while(lineElem) { + y++; + x = -1; - // - Then we will select the tile. and increment x to keep tiling that row. - tileElem = lineElem->FirstChildElement("tile"); - assert(tileElem != NULL); - while(tileElem) { - x++; - _tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT); + // - Then we will select the tile. and increment x to keep tiling that row. + tileElem = lineElem->FirstChildElement("tile"); + assert(tileElem != NULL); + while(tileElem) { + x++; + _tile[x][y].SetTileXY(x * TILE_WIDTH, y * TILE_HEIGHT); - // - Apply a teture to the tile. - dataElem = tileElem->FirstChildElement("tileTexture"); - assert(dataElem != NULL); - stringstream tilePath; - tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png"; - _tile[x][y].SetTileTexture(_tileTextures.Add(tilePath.str())); - // - Finished applying the texture, move to the next sibling. + // - Apply a teture to the tile. + dataElem = tileElem->FirstChildElement("tileTexture"); + assert(dataElem != NULL); + stringstream tilePath; + tilePath << "../Data/Media/Images/Tiles/" << dataElem->GetText() << ".png"; + _tile[x][y].SetTileTexture(_tileTextures.Add(tilePath.str())); + // - Finished applying the texture, move to the next sibling. - // - Check to see if the tile is solid or not. - dataElem = dataElem->NextSiblingElement("solidTile"); - assert(dataElem != NULL); - string tileSolidity = dataElem->GetText(); - assert(tileSolidity == "false" || tileSolidity == "true"); - if(tileSolidity == "false") - _tile[x][y].SetTileSolidity(false); - else - _tile[x][y].SetTileSolidity(true); - // + // - Check to see if the tile is solid or not. + dataElem = dataElem->NextSiblingElement("solidTile"); + assert(dataElem != NULL); + string tileSolidity = dataElem->GetText(); + assert(tileSolidity == "false" || tileSolidity == "true"); + if(tileSolidity == "false") + _tile[x][y].SetTileSolidity(false); + else + _tile[x][y].SetTileSolidity(true); + // - // - dataElem = dataElem->NextSiblingElement("entityTexture"); - assert(dataElem != NULL); - string entityName = dataElem->GetText(); - if(entityName != "null") { - stringstream entityPath; - entityPath << "../Data/Media/Images/Entities/" << entityName << ".png"; - _tile[x][y].SetEntityTexture(_entityTextures.AddAlpha(entityPath.str())); + // + dataElem = dataElem->NextSiblingElement("entityTexture"); + assert(dataElem != NULL); + string entityName = dataElem->GetText(); + if(entityName != "null") { + stringstream entityPath; + entityPath << "../Data/Media/Images/Entities/" << entityName << ".png"; + _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].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 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); + } + // - // - dataElem = dataElem->NextSiblingElement("solidEntity"); - assert(dataElem != NULL); - string entitySolidity = dataElem->GetText(); - assert(entitySolidity == "false" || entitySolidity == "true"); - if(entitySolidity == "false") - _tile[x][y].SetEntitySolidity(false); - else - _tile[x][y].SetEntitySolidity(true); - // + // + dataElem = dataElem->NextSiblingElement("solidEntity"); + assert(dataElem != NULL); + string entitySolidity = dataElem->GetText(); + assert(entitySolidity == "false" || entitySolidity == "true"); + if(entitySolidity == "false") + _tile[x][y].SetEntitySolidity(false); + else + _tile[x][y].SetEntitySolidity(true); + // - // - dataElem = dataElem->NextSiblingElement("zLevel"); - assert(dataElem != NULL); - _tile[x][y].SetZLevel(atoi(dataElem->GetText())); - // + // + dataElem = dataElem->NextSiblingElement("zLevel"); + assert(dataElem != NULL); + _tile[x][y].SetZLevel(atoi(dataElem->GetText())); + // - // - dataElem = dataElem->NextSiblingElement("mapTransition"); - assert(dataElem != NULL); - _tile[x][y].SetMapTransitionName(dataElem->GetText()); - // + // + dataElem = dataElem->NextSiblingElement("mapTransition"); + assert(dataElem != NULL); + _tile[x][y].SetMapTransitionName(dataElem->GetText()); + // - // - dataElem = dataElem->NextSiblingElement("mapTransX"); - assert(dataElem != NULL); - // int mapTransX = atoi(dataElem->GetText()); // not referenced - // + // + dataElem = dataElem->NextSiblingElement("mapTransX"); + assert(dataElem != NULL); + // int mapTransX = atoi(dataElem->GetText()); // not referenced + // - // - dataElem = dataElem->NextSiblingElement("mapTransY"); - assert(dataElem != NULL); - // int mapTransY = atoi(dataElem->GetText()); // not referenced - // + // + dataElem = dataElem->NextSiblingElement("mapTransY"); + assert(dataElem != NULL); + // int mapTransY = atoi(dataElem->GetText()); // not referenced + // - tileElem = tileElem->NextSiblingElement("tile"); - } - // + tileElem = tileElem->NextSiblingElement("tile"); + } + // - lineElem = lineElem->NextSiblingElement("line"); - } - // - } - // - levelWidth = x * TILE_WIDTH; - levelHeight = y * TILE_HEIGHT; - - // procedural generation - DoMagic(); + lineElem = lineElem->NextSiblingElement("line"); + } + // + } + // + levelWidth = x * TILE_WIDTH; + levelHeight = y * TILE_HEIGHT; - //character->Load(filename); + // procedural generation + DoMagic(); - NPC* npc = new NPC(this); - - int spawnX; - int spawnY; + //character->Load(filename); - //FindSpawnPoint(spawnX, spawnY); - //npc->SetXY(spawnX, spawnY); // try to uncomment this, try to find out what's going on.. --konom - npc->SetXY(100, 230); - npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); - _world.AddNPC(npc); + NPC* npc = new NPC(this); - npc = new NPC(this); - //FindSpawnPoint(spawnX, spawnY); - npc->SetXY(300, 250); - npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); - _world.AddNPC(npc); + int spawnX; + int spawnY; - npc = new NPC(this); - //FindSpawnPoint(spawnX, spawnY); - npc->SetXY(400, 100); - npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); - _world.AddNPC(npc); - - npc = new NPC(this); - //FindSpawnPoint(spawnX, spawnY); - npc->SetXY(200, 400); - npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); - _world.AddNPC(npc); - - npc = new NPC(this); - //FindSpawnPoint(spawnX, spawnY); - npc->SetXY(250, 250); - npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); - _world.AddNPC(npc); + //FindSpawnPoint(spawnX, spawnY); + //npc->SetXY(spawnX, spawnY); // try to uncomment this, try to find out what's going on.. --konom + npc->SetXY(100, 230); + npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); + _world.AddNPC(npc); + + npc = new NPC(this); + //FindSpawnPoint(spawnX, spawnY); + npc->SetXY(300, 250); + npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); + _world.AddNPC(npc); + + npc = new NPC(this); + //FindSpawnPoint(spawnX, spawnY); + npc->SetXY(400, 100); + npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); + _world.AddNPC(npc); + + npc = new NPC(this); + //FindSpawnPoint(spawnX, spawnY); + npc->SetXY(200, 400); + npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); + _world.AddNPC(npc); + + npc = new NPC(this); + //FindSpawnPoint(spawnX, spawnY); + npc->SetXY(250, 250); + npc->LoadSprites("../Data/Media/Images/Characters/template.png", 40,45); + _world.AddNPC(npc); } void LevelGen::Update(void) { - _world.Update(); - // Update the map so we can render when camera moves. + _world.Update(); + // Update the map so we can render when camera moves. } void LevelGen::Render(void) { - int xOrig = (camera.x / TILE_WIDTH) - 1; - int yOrig = (camera.y / TILE_HEIGHT) - 1; + int xOrig = (camera.x / TILE_WIDTH) - 1; + int yOrig = (camera.y / TILE_HEIGHT) - 1; - if (xOrig < 0) xOrig = 0; - if (yOrig < 0) yOrig = 0; + if (xOrig < 0) xOrig = 0; + if (yOrig < 0) yOrig = 0; - int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH) + 3; - int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT) + 3; + int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH) + 3; + int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT) + 3; - /* the fuck is this Allanis? --konom - if(xEnd < x) - xEnd++; - else - xEnd = x; + /* the fuck is this Allanis? --konom + if(xEnd < x) + xEnd++; + else + xEnd = x; - if(yEnd < y) - yEnd++; - else - yEnd = y; - */ + if(yEnd < y) + yEnd++; + else + yEnd = y; + */ - if (xEnd > x) xEnd = x; - if (yEnd > y) yEnd = y; - if (xEnd < 0) xEnd = 0; - if (yEnd < 0) yEnd = 0; + if (xEnd > x) xEnd = x; + if (yEnd > y) yEnd = y; + if (xEnd < 0) xEnd = 0; + if (yEnd < 0) yEnd = 0; - if (xOrig > xEnd) xOrig = xEnd - 1; - if (yOrig > yEnd) yOrig = yEnd - 1; + if (xOrig > xEnd) xOrig = xEnd - 1; + if (yOrig > yEnd) yOrig = yEnd - 1; - for(int i = xOrig; i < xEnd; i++) { - for(int j = yOrig; j < yEnd; j++) { - _tile[i][j].Render(); - } - } + for(int i = xOrig; i < xEnd; i++) { + for(int j = yOrig; j < yEnd; j++) { + _tile[i][j].Render(); + } + } - _world.Render(); + _world.Render(); } void LevelGen::Unload(void) { - _tileTextures.Unload(); - _entityTextures.Unload(); + _tileTextures.Unload(); + _entityTextures.Unload(); } void LevelGen::DoMagic(void) { - GenerateEntities("tree", 25); - GenerateEntities("hedge", 15); - GenerateEntities("barrel", 40); - MakeWalkingPaths(); + GenerateEntities("tree", 25); + GenerateEntities("hedge", 15); + GenerateEntities("barrel", 40); + MakeWalkingPaths(); } void LevelGen::GenerateEntities(const string& name, int frequency) { - int nextEntityGen = 1 + (rand() % frequency); - std::string filename = "../Data/Media/Images/Entities/" + name + ".png"; + int nextEntityGen = 1 + (rand() % frequency); + std::string filename = "../Data/Media/Images/Entities/" + name + ".png"; - for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) { - for(int y = 0; y < SCREEN_HEIGHT/64; y++) { - nextEntityGen--; - if(!_tile[x][y].GetTileSolidity() && !_tile[x][y].GetEntitySolitity() && nextEntityGen <= 0) { - _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].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2); - - _tile[x][y].SetEntitySolidity(true); - - nextEntityGen = 1 + (rand() % frequency); - } - } - } + for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) { + for(int y = 0; y < SCREEN_HEIGHT/64; y++) { + nextEntityGen--; + if(!_tile[x][y].GetTileSolidity() && !_tile[x][y].GetEntitySolitity() && nextEntityGen <= 0) { + _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].GetTileY() + TILE_HEIGHT / 2 - _tile[x][y].GetEntityHeight() / 2); + + _tile[x][y].SetEntitySolidity(true); + + nextEntityGen = 1 + (rand() % frequency); + } + } + } } void LevelGen::MakeWalkingPaths(void) { - int lastOpenY = rand() % 5; - - for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) { - bool pathFound = false; - - for(int y = 0; y < SCREEN_HEIGHT/64; y++) { - if(!_tile[x][y].GetEntitySolitity()) { - pathFound = true; - break; - } else { - lastOpenY = y; - } - } - - if(!pathFound) { - _tile[x][lastOpenY].SetEntityTexture(NULL); - _tile[x][lastOpenY].SetEntitySolidity(false); - } - } + int lastOpenY = rand() % 5; + + for(int x = 0; x < SCREEN_WIDTH/64 + 1; x++) { + bool pathFound = false; + + for(int y = 0; y < SCREEN_HEIGHT/64; y++) { + if(!_tile[x][y].GetEntitySolitity()) { + pathFound = true; + break; + } else { + lastOpenY = y; + } + } + + if(!pathFound) { + _tile[x][lastOpenY].SetEntityTexture(NULL); + _tile[x][lastOpenY].SetEntitySolidity(false); + } + } } void LevelGen::FindSpawnPoint(int& xArg, int& yArg) { - xArg = rand() % SCREEN_WIDTH; - yArg = rand() % SCREEN_HEIGHT; - - int tileX = xArg / 64; - int tileY = yArg / 64; - - if(!_tile[tileX][tileY].GetEntitySolitity() && !_world.HasNPCIn(xArg, yArg)) { - return; - } - - FindSpawnPoint(xArg, yArg); + xArg = rand() % SCREEN_WIDTH; + yArg = rand() % SCREEN_HEIGHT; + + int tileX = xArg / 64; + int tileY = yArg / 64; + + if(!_tile[tileX][tileY].GetEntitySolitity() && !_world.HasNPCIn(xArg, yArg)) { + return; + } + + FindSpawnPoint(xArg, yArg); } string LevelGen::GetCurrentMap(void) { - return _currentMap; + return _currentMap; } 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) { - return _tile[xArg + 1][yArg + 1].GetTileX(); + return _tile[xArg + 1][yArg + 1].GetTileX(); } 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) { - if(xArg > x || yArg > y || yArg < 0 || yArg < 0) { - return false; - } + if(xArg > x || yArg > y || yArg < 0 || yArg < 0) { + return false; + } - return _tile[xArg + 1][yArg + 1].GetEntitySolitity(); + return _tile[xArg + 1][yArg + 1].GetEntitySolitity(); } 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) { - return _tile[xArg + 1][yArg + 1].GetEntityY(); + return _tile[xArg + 1][yArg + 1].GetEntityY(); } 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) { - return _tile[xArg + 1][yArg + 1].GetEntityHeight(); + return _tile[xArg + 1][yArg + 1].GetEntityHeight(); } 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) { - return _tile[xArg + 1][yArg + 1].GetMapTransitionName(); + return _tile[xArg + 1][yArg + 1].GetMapTransitionName(); } 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) { - return _tile[xArg + 1][yArg + 1].GetMapTransitionY(); + return _tile[xArg + 1][yArg + 1].GetMapTransitionY(); }