UPDATE (please let me know if anyone found additional alternatives)
evilMonkeys cheat!!!
1 –FIXED
Under Sprite.cpp
Changed from:
Code:
bool Sprite::isValidLevelMove(int xpos, int ypos)
{
if (xpos >= 0 && xpos < level->getWidth() &&
ypos >= 0 && ypos < level->getHeight() &&
level->level[xpos][ypos] != TILE_WALL )
return true;
return false;
}
TO
Code:
bool Sprite::isValidLevelMove(int xpos, int ypos)
{
int currentX = (int)this->getX();
int currentY = (int)this->getY();
//Validate invalid diagonal coords
if ((currentX - 1) == xpos && (currentY - 1) == ypos)
return false;
else if ((currentX - 1) == xpos && (currentY + 1) == ypos)
return false;
else if ((currentX + 1) == xpos && (currentY - 1) == ypos)
return false;
else if ((currentX + 1) == xpos && (currentY + 1) == ypos)
return false;
if (xpos >= 0 && xpos < level->getWidth() &&
ypos >= 0 && ypos < level->getHeight() &&
level->level[xpos][ypos] != TILE_WALL )
return true;
return false;
}
2 –FIXED. To fix point 2, I changed the original code in level.cpp under “void Level::addEnemies” function.
Code:
void Level::addEnemies(int num, int speed)
{
int i = num;
while (i > 0)
{
int xpos = int((float(rand() % 100) / 100) * (width - 2) + 1);
int ypos = int((float(rand() % 100) / 100) * (height - 2) + 1);
if (level[xpos][ypos] != TILE_WALL)
{
Enemy *temp = new Enemy(this, drawArea, SPRITE_ENEMY, (float)xpos, float(ypos));
temp->setSpeed(speed);
temp->addGoal(player);
addNPC((Sprite *)temp);
i--;
}
}
}
to
Code:
void Level::addEnemies(int num, int speed)
{
int i = num;
while (i > 0)
{
int xpos = int((float(rand() % 100) / 100) * (width - 5) + 5);
int ypos = int((float(rand() % 100) / 100) * (height - 5) + 5);
if (level[xpos][ypos] != TILE_WALL)
{
Enemy *temp = new Enemy(this, drawArea, SPRITE_ENEMY, (float)xpos, float(ypos));
temp->setSpeed(speed);
temp->addGoal(player);
addNPC((Sprite *)temp);
i--;
}
}
}
3 - FIXED
Fixed using Aholio suggestion. I'll post as son as possible.
Player cheats
1 – FIXED. To fix this point I edit the mage.cpp under “Mage::castSpell” function.
Code:
void Mage::castSpell(void)
{
if (facingDirection.x == 0 && facingDirection.y == 0)
return;
if (facingDirection.y < -1 && facingDirection.y < -1)
return;
Fireball *temp = new Fireball(level, drawArea, SPRITE_FIREBALL, (int)pos.x + facingDirection.x,
(int)pos.y + facingDirection.y, facingDirection.x, facingDirection.y);
if (temp->move(facingDirection.x, facingDirection.y))
{
temp->update();
level->addNPC((Sprite *)temp);
}
else
update();
}
to
Code:
void Mage::castSpell(void)
{
if (facingDirection.x == 0 && facingDirection.y == 0)
return;
if (facingDirection.y < -1 && facingDirection.y < -1)
return;
if (!(isValidLevelMove(((int)pos.x + (int)facingDirection.x), ((int)pos.y + (int)facingDirection.y))))
return;
Fireball *temp = new Fireball(level, drawArea, SPRITE_FIREBALL, (int)pos.x + facingDirection.x,
(int)pos.y + facingDirection.y, facingDirection.x, facingDirection.y);
if (temp->move(facingDirection.x, facingDirection.y))
{
temp->update();
level->addNPC((Sprite *)temp);
}
else
update();
}
2 – FIXED
In AppFrame.cpp
Changed from
Code:
gameWindow->Connect(-1, -1, wxEVT_KEY_DWON,(wxObjectEventFunction) &AppFrame::OnKey, NULL, this);
TO
Code:
gameWindow->Connect(-1, -1, wxEVT_KEY_UP,(wxObjectEventFunction) &AppFrame::OnKey, NULL, this);
3 - FIXED - UPDATED
Changes made in Fireball.cpp and Mage.cpp
OLD CODE Fireball.cpp
Code:
void Fireball::idleUpdate(void)
{
if ((isValidLevelMove((int)pos.x, (int)pos.y)) && ((facingDirection.x + facingDirection.y) != 0))
{
if (Sprite::move(facingDirection.x, facingDirection.y))
{
list <Sprite *>::iterator Iter;
for (Iter = level->npc.begin(); Iter != level->npc.end(); Iter++)
{
if ((*Iter)->classID != classID &&
(int)(*Iter)->getX() ==(int)pos.x && (int)(*Iter)->getY() ==(int)pos.y)
{
(*Iter)->addLives(-1);
addLives(-1);
}
}
}
else
addLives(-1);
}
}
CHANGED TO
Code:
void Fireball::idleUpdate(void)
{
int x = pos.x;
int y = pos.y;
if ((isValidLevelMove((int)pos.x, (int)pos.y)) && ((facingDirection.x + facingDirection.y) != 0))
{
if (Sprite::move(facingDirection.x, facingDirection.y))
{
list <Sprite *>::iterator Iter;
for (Iter = level->npc.begin(); Iter != level->npc.end(); Iter++)
{
if ((*Iter)->classID != classID &&
(int)(*Iter)->getX() == (int)pos.x && (int)(*Iter)->getY() ==(int)pos.y ||
(int)(*Iter)->getX() == x && (int)(*Iter)->getY() == y)
{
(*Iter)->addLives(-1);
addLives(-1);
}
}
}
else
addLives(-1);
}
}
OLD CODE Mage.cpp
Code:
void Mage::castSpell(void)
{
if (facingDirection.x == 0 && facingDirection.y == 0)
return;
if (facingDirection.y < -1 && facingDirection.y < -1)
return;
if (!(isValidLevelMove(((int)pos.x + (int)facingDirection.x), ((int)pos.y + (int)facingDirection.y))))
return;
Fireball *temp = new Fireball(level, drawArea, SPRITE_FIREBALL, (int)pos.x + facingDirection.x,
(int)pos.y + facingDirection.y, facingDirection.x, facingDirection.y);
if (temp->move(facingDirection.x, facingDirection.y))
{
temp->update();
level->addNPC((Sprite *)temp);
}
else
update();
}
CHANGED TO
Code:
void Mage::castSpell(void)
{
if (facingDirection.x == 0 && facingDirection.y == 0)
return;
if (facingDirection.y < -1 && facingDirection.y < -1)
return;
if (!(isValidLevelMove(((int)pos.x + (int)facingDirection.x), ((int)pos.y + (int)facingDirection.y))))
return;
Fireball *temp = new Fireball(level, drawArea, SPRITE_FIREBALL, (int)pos.x,
(int)pos.y, facingDirection.x, facingDirection.y);
if (temp->move(facingDirection.x, facingDirection.y))
{
temp->update();
level->addNPC((Sprite *)temp);
update();
}
else
update();
}
Game start Window
1 – FIXED. Using AppFrame.cpp under AppFrame::AppFrame , changed the following
Code:
menuFile->Append(ID_New,"&New);
menuFile->Append(ID_Load,"&Load");
menuFile->AppendSeparator();
menuFile->Append(ID_About,"&About");
menuFile->AppendSeparator();
menuFile->Append(ID_Exit,"&Exit");
to
Code:
menuFile->Append(ID_New,_T("New\tCtrl-N"));
menuFile->Append(ID_Load,_T("Load\tCtrl-L"));
menuFile->AppendSeparator();
menuFile->Append(ID_About,_T("About\tCtrl-A"));
menuFile->AppendSeparator();
menuFile->Append(ID_Exit,_T("Exit\tCtrl-E"));
2 – FIXED. Using AppFrame.cpp under “AppFrame::AppFrame “ added the following at the very end of the code
Code:
gameWindow->SetFocus();
Additional suggestions are welcome.