From a7367551c668890becb2a060d6c194bdcb8cd9ad Mon Sep 17 00:00:00 2001 From: Tamir Atias Date: Sun, 5 Feb 2012 18:56:29 +0200 Subject: [PATCH] [Remove] Transitions from map file. [Fix] Bug in which NPCs collide with themselves. --- Data/Media/Maps/map | 316 +++++++--------------------- src/libUnuk/Engine/WorldManager.cpp | 6 +- src/libUnuk/Engine/WorldManager.h | 3 +- src/libUnuk/LevelGen/LevelGen.cpp | 2 +- 4 files changed, 87 insertions(+), 240 deletions(-) diff --git a/Data/Media/Maps/map b/Data/Media/Maps/map index 1bd5088..17d27ad 100644 --- a/Data/Media/Maps/map +++ b/Data/Media/Maps/map @@ -19,9 +19,7 @@ 100 - null - 0 - 0 + @@ -33,9 +31,7 @@ 100 - null - 0 - 0 + @@ -47,9 +43,7 @@ 100 - null - 0 - 0 + @@ -61,9 +55,7 @@ 100 - null - 0 - 0 + @@ -75,9 +67,7 @@ 100 - null - 0 - 0 + @@ -89,9 +79,7 @@ 100 - null - 0 - 0 + @@ -103,9 +91,7 @@ 100 - null - 0 - 0 + @@ -260,9 +246,7 @@ 100 - null - 0 - 0 + @@ -274,9 +258,7 @@ 100 - null - 0 - 0 + @@ -288,9 +270,7 @@ 100 - null - 0 - 0 + @@ -302,9 +282,7 @@ 100 - null - 0 - 0 + @@ -316,9 +294,7 @@ 100 - null - 0 - 0 + @@ -330,9 +306,7 @@ 100 - null - 0 - 0 + @@ -344,9 +318,7 @@ 100 - null - 0 - 0 + @@ -358,9 +330,7 @@ 100 - null - 0 - 0 + @@ -515,9 +485,7 @@ 100 - null - 0 - 0 + @@ -529,9 +497,7 @@ 100 - null - 0 - 0 + @@ -543,9 +509,7 @@ -1 - null - 0 - 0 + @@ -557,9 +521,7 @@ -1 - null - 0 - 0 + @@ -571,9 +533,7 @@ -1 - null - 0 - 0 + @@ -585,9 +545,7 @@ 100 - null - 0 - 0 + @@ -599,9 +557,7 @@ 100 - null - 0 - 0 + @@ -613,9 +569,7 @@ 100 - null - 0 - 0 + @@ -769,9 +723,7 @@ 100 - null - 0 - 0 + @@ -783,9 +735,7 @@ 100 - null - 0 - 0 + @@ -797,9 +747,7 @@ 100 - null - 0 - 0 + @@ -811,9 +759,7 @@ 100 - null - 0 - 0 + @@ -825,9 +771,7 @@ 100 - null - 0 - 0 + @@ -839,9 +783,7 @@ 100 - null - 0 - 0 + @@ -853,9 +795,7 @@ 100 - null - 0 - 0 + @@ -867,9 +807,7 @@ 100 - null - 0 - 0 + @@ -1024,9 +962,7 @@ 100 - null - 0 - 0 + @@ -1038,9 +974,7 @@ 100 - null - 0 - 0 + @@ -1052,9 +986,7 @@ 100 - null - 0 - 0 + @@ -1066,9 +998,7 @@ 100 - null - 0 - 0 + @@ -1080,9 +1010,7 @@ 100 - null - 0 - 0 + @@ -1094,9 +1022,7 @@ 100 - null - 0 - 0 + @@ -1108,9 +1034,7 @@ 100 - null - 0 - 0 + @@ -1122,9 +1046,7 @@ 100 - null - 0 - 0 + @@ -1279,9 +1201,7 @@ 100 - null - 0 - 0 + @@ -1293,9 +1213,7 @@ 100 - null - 0 - 0 + @@ -1307,9 +1225,7 @@ 100 - null - 0 - 0 + @@ -1321,9 +1237,7 @@ 100 - null - 0 - 0 + @@ -1335,9 +1249,7 @@ 100 - null - 0 - 0 + @@ -1349,9 +1261,7 @@ 100 - null - 0 - 0 + @@ -1363,9 +1273,7 @@ 100 - null - 0 - 0 + @@ -1377,9 +1285,7 @@ 100 - null - 0 - 0 + @@ -1533,9 +1439,7 @@ 100 - null - 0 - 0 + @@ -1547,9 +1451,7 @@ 100 - null - 0 - 0 + @@ -1561,9 +1463,7 @@ 100 - null - 0 - 0 + @@ -1575,9 +1475,7 @@ 100 - null - 0 - 0 + @@ -1589,9 +1487,7 @@ 100 - null - 0 - 0 + @@ -1603,9 +1499,7 @@ 100 - null - 0 - 0 + @@ -1617,9 +1511,7 @@ 100 - null - 0 - 0 + @@ -1631,9 +1523,7 @@ 100 - null - 0 - 0 + @@ -1787,9 +1677,7 @@ 100 - null - 0 - 0 + @@ -1801,9 +1689,7 @@ 100 - null - 0 - 0 + @@ -1815,9 +1701,7 @@ 100 - null - 0 - 0 + @@ -1829,9 +1713,7 @@ 100 - null - 0 - 0 + @@ -1843,9 +1725,7 @@ 100 - null - 0 - 0 + @@ -1857,9 +1737,7 @@ 100 - null - 0 - 0 + @@ -1871,9 +1749,7 @@ 100 - null - 0 - 0 + @@ -1885,9 +1761,7 @@ 100 - null - 0 - 0 + @@ -2042,9 +1916,7 @@ 100 - null - 0 - 0 + @@ -2056,9 +1928,7 @@ 100 - null - 0 - 0 + @@ -2070,9 +1940,7 @@ 100 - null - 0 - 0 + @@ -2084,9 +1952,7 @@ 100 - null - 0 - 0 + @@ -2098,9 +1964,7 @@ 100 - null - 0 - 0 + @@ -2112,9 +1976,7 @@ 100 - null - 0 - 0 + @@ -2126,9 +1988,7 @@ 100 - null - 0 - 0 + @@ -2140,9 +2000,7 @@ 100 - null - 0 - 0 + @@ -2297,9 +2155,7 @@ 100 - null - 0 - 0 + @@ -2311,9 +2167,7 @@ 100 - null - 0 - 0 + @@ -2325,9 +2179,7 @@ 100 - null - 0 - 0 + @@ -2339,9 +2191,7 @@ 100 - null - 0 - 0 + @@ -2353,9 +2203,7 @@ 100 - null - 0 - 0 + @@ -2367,9 +2215,7 @@ 100 - null - 0 - 0 + @@ -2381,9 +2227,7 @@ 100 - null - 0 - 0 + @@ -2395,9 +2239,7 @@ 100 - null - 0 - 0 + diff --git a/src/libUnuk/Engine/WorldManager.cpp b/src/libUnuk/Engine/WorldManager.cpp index a54c53e..8636beb 100644 --- a/src/libUnuk/Engine/WorldManager.cpp +++ b/src/libUnuk/Engine/WorldManager.cpp @@ -75,10 +75,14 @@ void WorldManager::CreateNPC(int x, int y) { _npcs.push_back(npc); } -bool WorldManager::CheckCollision(const SDL_Rect& charRect) { +bool WorldManager::CheckCollision(const SDL_Rect& charRect, Character* exclude) { for(std::list::iterator i = _npcs.begin(); i != _npcs.end(); ++i) { NPC* npc = (*i); + if(npc == exclude) { + continue; + } + SDL_Rect npcRect; npcRect.x = npc->GetX(); npcRect.y = npc->GetY(); diff --git a/src/libUnuk/Engine/WorldManager.h b/src/libUnuk/Engine/WorldManager.h index 12a7309..fe1cfb1 100644 --- a/src/libUnuk/Engine/WorldManager.h +++ b/src/libUnuk/Engine/WorldManager.h @@ -1,6 +1,7 @@ #pragma once #include +class Character; class NPC; class Player; class LevelGen; @@ -21,7 +22,7 @@ public: NPC* GetNPCAt(int xArg, int yArg); void CreateNPC(int x, int y); - bool CheckCollision(const SDL_Rect& charRect); + bool CheckCollision(const SDL_Rect& charRect, Character* exclude); int GetNPCCount() { return _npcs.size(); } diff --git a/src/libUnuk/LevelGen/LevelGen.cpp b/src/libUnuk/LevelGen/LevelGen.cpp index b9fb795..c5a34eb 100644 --- a/src/libUnuk/LevelGen/LevelGen.cpp +++ b/src/libUnuk/LevelGen/LevelGen.cpp @@ -323,7 +323,7 @@ void LevelGen::MoveIfPossible(Character* character, float xVel, float yVel) { } } - if(_world.CheckCollision(charRect)) { + if(_world.CheckCollision(charRect, character)) { return; }