[Fix] Supposedly fixed spawning on top of NPCs.
This commit is contained in:
parent
90e3ff7a22
commit
cc258c35e0
@ -824,8 +824,8 @@
|
|||||||
<tileTexture>grass</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>false</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>cabin</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>true</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
|
|
||||||
<zLevel>100</zLevel>
|
<zLevel>100</zLevel>
|
||||||
|
|
||||||
@ -2052,8 +2052,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2066,8 +2066,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2080,8 +2080,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2094,8 +2094,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2108,8 +2108,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2122,8 +2122,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2136,8 +2136,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2150,8 +2150,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2164,8 +2164,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
@ -2178,8 +2178,8 @@
|
|||||||
</tile>
|
</tile>
|
||||||
|
|
||||||
<tile>
|
<tile>
|
||||||
<tileTexture>MessyBrickWall</tileTexture>
|
<tileTexture>grass</tileTexture>
|
||||||
<solidTile>true</solidTile>
|
<solidTile>false</solidTile>
|
||||||
|
|
||||||
<entityTexture>null</entityTexture>
|
<entityTexture>null</entityTexture>
|
||||||
<solidEntity>false</solidEntity>
|
<solidEntity>false</solidEntity>
|
||||||
|
@ -29,7 +29,6 @@ void Game::Load(const string& savegameIDArg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gameNavVal_t Game::Run(void) {
|
gameNavVal_t Game::Run(void) {
|
||||||
_player->SetXY(400, 400);
|
|
||||||
_player->LoadSprites("../Data/Media/Images/Characters/Player.png", 40, 45);
|
_player->LoadSprites("../Data/Media/Images/Characters/Player.png", 40, 45);
|
||||||
|
|
||||||
int fps = 0;
|
int fps = 0;
|
||||||
|
@ -57,15 +57,15 @@ NPC* WorldManager::GetNPC(int index) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldManager::HasNPCIn(int xArg, int yArg) {
|
NPC* WorldManager::GetNPCAt(int xArg, int yArg) {
|
||||||
for(std::list<NPC*>::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
|
for(std::list<NPC*>::iterator i = _npcs.begin(); i != _npcs.end(); ++i) {
|
||||||
NPC* npc = (*i);
|
NPC* npc = (*i);
|
||||||
if(xArg >= npc->GetX() && xArg <= (npc->GetX() + npc->GetWidth()) &&
|
if(xArg >= npc->GetX() && xArg <= (npc->GetX() + npc->GetWidth()) &&
|
||||||
yArg >= npc->GetY() && yArg <= (npc->GetY() + npc->GetHeight())) {
|
yArg >= npc->GetY() && yArg <= (npc->GetY() + npc->GetHeight())) {
|
||||||
return true;
|
return npc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldManager::CreateNPC(int x, int y) {
|
void WorldManager::CreateNPC(int x, int y) {
|
||||||
|
@ -16,9 +16,9 @@ public:
|
|||||||
void AddNPC(NPC* npc);
|
void AddNPC(NPC* npc);
|
||||||
void RemoveNPC(int index);
|
void RemoveNPC(int index);
|
||||||
NPC* GetNPC(int index);
|
NPC* GetNPC(int index);
|
||||||
|
NPC* GetNPCAt(int xArg, int yArg);
|
||||||
void CreateNPC(int x, int y);
|
void CreateNPC(int x, int y);
|
||||||
|
|
||||||
bool HasNPCIn(int xArg, int yArg);
|
|
||||||
|
|
||||||
int GetNPCCount() { return _npcs.size(); }
|
int GetNPCCount() { return _npcs.size(); }
|
||||||
|
|
||||||
|
@ -241,16 +241,24 @@ void LevelGen::FindSpawnPoint(int& xArg, int& yArg, int objWidth, int objHeight)
|
|||||||
xArg = rand() % (BOUNDARIES_X * TILE_WIDTH);
|
xArg = rand() % (BOUNDARIES_X * TILE_WIDTH);
|
||||||
yArg = rand() % (BOUNDARIES_Y * TILE_HEIGHT);
|
yArg = rand() % (BOUNDARIES_Y * TILE_HEIGHT);
|
||||||
|
|
||||||
if(_world.HasNPCIn(xArg, yArg)) {
|
|
||||||
goto findNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Rect objRect;
|
SDL_Rect objRect;
|
||||||
objRect.x = xArg;
|
objRect.x = xArg;
|
||||||
objRect.y = yArg;
|
objRect.y = yArg;
|
||||||
objRect.w = objWidth;
|
objRect.w = objWidth;
|
||||||
objRect.h = objHeight;
|
objRect.h = objHeight;
|
||||||
|
|
||||||
|
NPC* npc = _world.GetNPCAt(xArg, yArg);
|
||||||
|
if(npc) {
|
||||||
|
SDL_Rect npcRect;
|
||||||
|
npcRect.x = npc->GetX();
|
||||||
|
npcRect.y = npc->GetY();
|
||||||
|
npcRect.w = npc->GetWidth();
|
||||||
|
npcRect.h = npc->GetHeight();
|
||||||
|
|
||||||
|
if(CheckCollisionRect(npcRect, objRect))
|
||||||
|
goto findNext;
|
||||||
|
}
|
||||||
|
|
||||||
for(int x = 0; x < BOUNDARIES_X; x++) {
|
for(int x = 0; x < BOUNDARIES_X; x++) {
|
||||||
for(int y = 0; y < BOUNDARIES_Y; y++) {
|
for(int y = 0; y < BOUNDARIES_Y; y++) {
|
||||||
if(_tile[x][y].GetTileSolidity()) {
|
if(_tile[x][y].GetTileSolidity()) {
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
MapTile _tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE];
|
MapTile _tile[TILE_ARRAY_SIZE][TILE_ARRAY_SIZE];
|
||||||
|
|
||||||
static const int BOUNDARIES_X = (SCREEN_WIDTH / TILE_WIDTH) - 2;
|
static const int BOUNDARIES_X = (SCREEN_WIDTH / TILE_WIDTH) - 2;
|
||||||
static const int BOUNDARIES_Y = (SCREEN_HEIGHT / TILE_HEIGHT) - 2;
|
static const int BOUNDARIES_Y = (SCREEN_HEIGHT / TILE_HEIGHT) - 1;
|
||||||
|
|
||||||
TextureManager _tileTextures;
|
TextureManager _tileTextures;
|
||||||
TextureManager _entityTextures;
|
TextureManager _entityTextures;
|
||||||
|
Loading…
Reference in New Issue
Block a user