   Console game problem...
  I got one problem In my console RPG project now... In my Character (player) class, in CheckCollision method I need to identify which of unique enemy my player hitted, i need to get pointer to that enemy, how i can do this? I was thinking of multidimensional array to store enemy locations and pointers to them...CheckCollision() is in character.cppHere's the code to character.cpp:#include "character.h"#include <windows.h>#include "engine.h"Character::Character(Engine *en,Map * map, char up, char down, char left, char right){gameMap = map;upKey = up;downKey = down;leftKey = left;rightKey = right;eng = en;}void Character::Move(int posX,int posY){if(!CheckCollision(posX,posY)){eng->erasePlayer(this);mPosX += posX;mPosY += posY;eng->drawPlayer(this);}}void Character::UpdatePlayer(char c){switch(c){case 'w':Move(0,-1);break;case 's':Move(0,1);break;case 'a':Move(-1,0);break;case 'd':Move(1,0);break;};}bool Character::CheckCollision(int posX,int posY){    int finalX = mPosX + posX;int finalY = mPosY + posY;if(gameMap->GetMapCoord(finalX,finalY) == WALL){return true;}else if(gameMap->GetMapCoord(finalX,finalY) == FIGHTER){int msg = MessageBox(0,L"This is Fighter",L"Combat Mode",MB_YESNO);switch(msg){case IDYES://attack codebreak;case IDNO://retreat codebreak;};return true;}else if(gameMap->GetMapCoord(finalX,finalY) == WIZARD){MessageBox(0,L"This is Wizard",L"Combat Mode",MB_OK);return true;}else if(gameMap->GetMapCoord(finalX,finalY) == BOSS){MessageBox(0,L"This is Boss",L"Combat Mode",MB_OK);return true;}return false;}void Character::StartPos(){mPosX = 1;mPosY = 1;}
  I'll try to make this problem clearer to you. For example i have to enemies of type fighter, one name is "Bob" and other is "Bill" they have same level cause they are both fighters, but different hit points and HP, I need to recognise which of enemy (Bob or Bill) I collide in CheckCollision meyhod, how canI do this?   ;  The way I did this for my simple game was something like this:I have an EntityManager class that is capable of creating, destroying and otherwise managing entities. My 'map' is basically simply a 2D array of entity IDs. When I request the entity manager to create a new entity, what I get as a return value is the ID of the entity created. I insert this ID into the map at the corresponding position.So, when I need to get a pointer to a specific entity at a specific position on the map, I get the ID at the desired position and call EntityManager::getEntity(ID). getEntity() returns the pointer to the entity with the given ID. To speed up this look-up my EntityManager contains a hash table with entity IDs as keys and pointers to entities as values.Originally I had my map made up of simply pointers to entities. In your case, perhaps you could have an entity manager as well that contains a 2D array of entity pointers; you simply index to this array with the x and y positions to get the entity?   ;  Ok, this would look perfect, but how I can code in 2D array to hold pointers to enemies? How to represent this in code?   ;  I think I will create new class (like your entity) that has minimum three members - x position ID, y position ID and pointer to enemy, and then I initialize enemy in constructor i will also create new entity there, but how i can then get that entity, can you help me?   ;  I'm not sure I understand what you mean, but hopefully this piece of code will give some ideas. It is only a simple outline; in the real game you of course have to keep the visible map and the internal EntityManager map (or whatever you decide to make) in sync etc.// Map and entity management// Simple example#include <iostream>#include <string>#include <list>#include <vector>const int ROWS = 10;const int COLUMNS = 10;const int PLAYERSTARTX = 5;const int PLAYERSTARTY = 5;const int ENEMYSTARTX = 5;const int ENEMYSTARTY = 6;class Position{public:    Position(int xPos = 0, int yPos = 0)    : m_x(xPos), m_y(yPos)    {}    int m_x;    int m_y;};class Entity{public:    Entity(const Position& pos, const std::string& name, int hp, char representation)    : m_position(pos), m_name(name), m_hp(hp), m_representation(representation)    {}   Position getPosition() const    {   return m_position;    }   const std::string& getName() const    {   return m_name;    }   int getHp() const    {   return m_hp;    }   void moveTo(const Position& position)    {   m_position = position;    }   char getRepresentation() const    {   return m_representation;    }    private:    Position m_position;    std::string m_name;    int m_hp;    char m_representation;    };class EntityManager{public:    static char createEntity(const Position& position,    const std::string& name,    int hp, char representation)    {   Entity* newEntity = new Entity(position, name, hp, representation); m_entityList.push_back(newEntity);   m_entityPositions[position.m_x][position.m_y] = newEntity; return representation;    }   static void deleteAll()    {   std::list<Entity*>::iterator it;   for (it = m_entityList.begin(); it != m_entityList.end(); ++it)   {  delete *it;   } m_entityList.clear();    }   static Entity* getEntityAt(const Position& position)    {   return m_entityPositions[position.m_x][position.m_y];    }   static void init()    {   resizePositions();    }   private:    static std::list<Entity*> m_entityList;   static std::vector<std::vector<Entity*> > m_entityPositions; static void resizePositions()    {   std::vector<Entity*> newColumn;   newColumn.resize(ROWS, 0);   for (int column = 0; column < COLUMNS; ++column)   {  m_entityPositions.push_back(newColumn);   }    }    };std::list<Entity*>EntityManager::m_entityList;std::vector<std::vector<Entity*> >EntityManager::m_entityPositions;class Map{public:    Map(int rows = ROWS, int columns = COLUMNS)    : m_rows(rows), m_columns(columns)    {   std::vector<char> newColumn; for (int column = 0; column < m_columns; ++column)   {  m_map.push_back(newColumn);  for (int row = 0; row < m_rows; ++row)  { m_map[column].push_back('.');  if (column == 0 || column == m_columns - 1 ||row == 0 || row == m_rows - 1)m_map[column][row] = '#'; else if (column == PLAYERSTARTX && row == PLAYERSTARTY) {char temp =EntityManager::createEntity(Position(column, row),   "player",   100,   '@');   m_map[column][row] = temp; } else if (column == ENEMYSTARTX && row == ENEMYSTARTY) {char temp =EntityManager::createEntity(Position(column, row),   "enemy",   50000,   'B');   m_map[column][row] = temp; }  }   }    }    char getTypeAt(const Position& position) const    {   return m_map[position.m_x][position.m_y];    }    private:    int m_rows;    int m_columns;    std::vector<std::vector<char> > m_map;};void printMap(const Map& map){    for (int row = 0; row < ROWS; ++row)    {   for (int column = 0; column < COLUMNS; ++column)   {  std::cout << map.getTypeAt(Position(column, row));   }   std::cout << std::endl;    }}void printEnemy(const Entity& entity){    std::cout << "Name: " << entity.getName() << "\n";    std::cout << "Hp: " << entity.getHp() << "\n";}int main(){    EntityManager::init();    Map map;   printMap(map);   std::cout << "You are now at position ("    << PLAYERSTARTX << ", "    << PLAYERSTARTY << ").\n";    std::cout << "The enemy is at position ("    << ENEMYSTARTX << ", "    << ENEMYSTARTY << ").\n";   std::cout << "You now try to move at the enemy position.\n";    std::cout << "Perform moves pla pla pla.\n";    std::cout << "Oops, the position contains an enemy with"    << " the following information.\n\n";   Entity* enemy =EntityManager::getEntityAt(Position(ENEMYSTARTX, ENEMYSTARTY));   printEnemy(*enemy);   std::cout << "The enemy looks pretty tough...\n";    std::cout << "Nice knowing you.\n";   EntityManager::deleteAll();   return 0;}