From aa8e420af5268c5e4d76154af778fa25192198ae Mon Sep 17 00:00:00 2001 From: Anselme Date: Fri, 18 Mar 2016 12:16:09 +0100 Subject: [PATCH] fixed coordinates bug --- app/rpgmodule.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/rpgmodule.cpp b/app/rpgmodule.cpp index 6860bdd..d866592 100644 --- a/app/rpgmodule.cpp +++ b/app/rpgmodule.cpp @@ -191,7 +191,7 @@ QString RPGModule::lookAt(RPGCharacter *c, QString target) { if(target.compare("around") == 0) { - int terrain = WORLDMAP[c->x][c->y]; + int terrain = WORLDMAP[c->y][c->x]; if(terrain == VILLAGE) { Village *v = getVillage(c); @@ -216,13 +216,13 @@ QString RPGModule::lookAt(RPGCharacter *c, QString target) return QString("%1 is in %2").arg(c->pseudo).arg(getTerrainName(terrain)); } else if(target.compare("north") == 0 || target.compare("n") == 0) - return QString("%1 looks north and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->x-1][c->y])); + return QString("%1 looks north and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->y-1][c->x])); else if(target.compare("south") == 0 || target.compare("s") == 0) - return QString("%1 looks south and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->x+1][c->y])); + return QString("%1 looks south and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->y+1][c->x])); else if(target.compare("west") == 0 || target.compare("w") == 0) - return QString("%1 looks west and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->x][c->y-1])); + return QString("%1 looks west and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->y][c->x-1])); else if(target.compare("east") == 0 || target.compare("e") == 0) - return QString("%1 looks east and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->x][c->y+1])); + return QString("%1 looks east and sees %2").arg(c->pseudo).arg(getTerrainName(WORLDMAP[c->y][c->x+1])); else return QString("%1 is not a valid target").arg(target); } @@ -245,7 +245,7 @@ QString RPGModule::eventInteract(RPGCharacter *c, QString target) QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) { - char terrainType = WORLDMAP[c->x][c->y]; + char terrainType = WORLDMAP[c->y][c->x]; QString direction; QString currentArea = getTerrainName(terrainType); bool blocked = false; @@ -255,7 +255,7 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) { if(dir.compare("north") == 0 || dir.compare("n") == 0) { - bool isDiff = repeat && terrainType != WORLDMAP[c->x-1][c->y]; + bool isDiff = repeat && terrainType != WORLDMAP[c->y-1][c->x]; if(c->y == 0 || (isDiff && dist != 0)) blocked = true; else @@ -269,7 +269,7 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) } else if(dir.compare("south") == 0 || dir.compare("s") == 0) { - bool isDiff = repeat && terrainType != WORLDMAP[c->x+1][c->y]; + bool isDiff = repeat && terrainType != WORLDMAP[c->y+1][c->x]; if(c->y == 24 || (isDiff && dist != 0)) blocked = true; else @@ -283,7 +283,7 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) } else if(dir.compare("west") == 0 || dir.compare("w") == 0) { - bool isDiff = repeat && terrainType != WORLDMAP[c->x][c->y-1]; + bool isDiff = repeat && terrainType != WORLDMAP[c->y][c->x-1]; if(c->x == 0 || (isDiff && dist != 0)) blocked = true; else @@ -297,7 +297,7 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) } else if(dir.compare("east") == 0 || dir.compare("e") == 0) { - bool isDiff = repeat && terrainType != WORLDMAP[c->x][c->y+1]; + bool isDiff = repeat && terrainType != WORLDMAP[c->y][c->x+1]; if(c->x == 24 || (isDiff && dist != 0)) blocked = true; else @@ -327,12 +327,12 @@ QString RPGModule::playerTravel(RPGCharacter *c, QString dir, bool repeat) return QString("%1 cannot go %2, a hill is blocking his way").arg(c->pseudo).arg(direction); } - char newTerrainType = WORLDMAP[c->x][c->y]; + char newTerrainType = WORLDMAP[c->y][c->x]; if(terrainType == newTerrainType) return QString("%1 is traveling %2 and is still in %3").arg(c->pseudo).arg(direction).arg(currentArea); else return QString("%1 is traveling %2, leaving %3 and entering %4") - .arg(c->pseudo).arg(direction).arg(currentArea).arg(getTerrainName(WORLDMAP[c->x][c->y])); + .arg(c->pseudo).arg(direction).arg(currentArea).arg(getTerrainName(WORLDMAP[c->y][c->x])); } bool RPGModule::messageHandler(Message msg)