std::list<C_OBJ*>::iterator itorM = m_cObjMgr.getMonsterBulletBegin();
std::list<C_OBJ*>::iterator itor = m_cObjMgr.getPlayerBegin();
std::list<C_OBJ*>::iterator itorP = m_cObjMgr.getPlayerBulletBegin();
std::list<C_OBJ*>::iterator itorMs = m_cObjMgr.getMonsterBegin();
while (itor != m_cObjMgr.getPlayerEnd())
{
C_OBJ *pObj = *itor;
int getRenderId = pObj->getRenderId();
int nWidht = m_cDcMgr.getWidht(getRenderId);
int nHeight = m_cDcMgr.getHeight(getRenderId);
BitBlt(m_cDcMgr.getDc(2), (int)pObj->getPositionX(), (int)pObj->getPositionY(), nWidht, nHeight, m_cDcMgr.getDc(getRenderId), 0, 0, SRCCOPY);
m_nPlayerPosX = (int)pObj->getPositionX();
m_nPlayerPosY = (int)pObj->getPositionY();
pObj->setMonsterBulletRECT(m_nMonsterBulltePosY, m_nMonsterBulltePosY + nHeight, m_nMonsterBulltePosX, m_nMonsterBulltePosX + nWidht);
pObj->setPlayerRECT(m_nPlayerPosY, m_nPlayerPosY + nHeight, m_nPlayerPosX, m_nPlayerPosX + nWidht);
if (pObj->getRECT())
{
m_cObjMgr.m_listPlayer.erase(itor++);
}
else
itor++;
}
while (itorM != m_cObjMgr.getMonsterBulletEnd())
{
C_OBJ *pObjm = *itorM;
int getRenderId = pObjm->getRenderId();
int nWidht = m_cDcMgr.getWidht(getRenderId);
int nHeight = m_cDcMgr.getHeight(getRenderId);
BitBlt(m_cDcMgr.getDc(2), (int)pObjm->getPositionX(), (int)pObjm->getPositionY(), nWidht, nHeight, m_cDcMgr.getDc(getRenderId), 0, 0, SRCCOPY);
m_nMonsterBulltePosX = (int)pObjm->getPositionX(); m_nMonsterBulltePosY = (int)pObjm->getPositionY();
pObjm->setMonsterBulletRECT(m_nMonsterBulltePosY, m_nMonsterBulltePosY + nHeight, m_nMonsterBulltePosX, m_nMonsterBulltePosX + nWidht);
pObjm->setPlayerRECT(m_nPlayerPosY, m_nPlayerPosY + nHeight, m_nPlayerPosX, m_nPlayerPosX + nWidht);
if (pObjm->getRECT())
{
m_cObjMgr.m_listMonsterBullet.erase(itorM++);
}
else
itorM++;
}
while (itorMs != m_cObjMgr.getMonsterEnd())
{
C_OBJ *pObjMs = *itorMs;
int getRenderId = pObjMs->getRenderId();
int nWidht = m_cDcMgr.getWidht(getRenderId);
int nHeight = m_cDcMgr.getHeight(getRenderId);
BitBlt(m_cDcMgr.getDc(2), (int)pObjMs->getPositionX(), (int)pObjMs->getPositionY(), nWidht, nHeight, m_cDcMgr.getDc(getRenderId), 0, 0, SRCCOPY);
m_nMonsterPosX = (int)pObjMs->getPositionX(); m_nMonsterPosY = (int)pObjMs->getPositionY();
pObjMs->setPlayerBullteRECT(m_nPlayerBulltePosY, m_nPlayerBulltePosY + nHeight, m_nPlayerBulltePosX, m_nPlayerBulltePosX + nWidht);
pObjMs->setMonsterRECT(m_nMonsterPosY, m_nMonsterPosY + nHeight, m_nMonsterPosX, m_nMonsterPosX + nWidht);
if (pObjMs->getPlayerBulletRECT())
{
m_cObjMgr.m_listMonster.erase(itorMs++);
}
else
itorMs++;
}
while (itorP != m_cObjMgr.getPlayerBulletEnd())
{
C_OBJ *pObjp = *itorP;
int getRenderId = pObjp->getRenderId();
int nWidht = m_cDcMgr.getWidht(getRenderId);
int nHeight = m_cDcMgr.getHeight(getRenderId);
BitBlt(m_cDcMgr.getDc(2), (int)pObjp->getPositionX(), (int)pObjp->getPositionY(), nWidht, nHeight, m_cDcMgr.getDc(getRenderId), 0, 0, SRCCOPY);
m_nPlayerBulltePosX = (int)pObjp->getPositionX(); m_nPlayerBulltePosY = (int)pObjp->getPositionY();
pObjp->setPlayerBullteRECT(m_nPlayerBulltePosY, m_nPlayerBulltePosY + nHeight, m_nPlayerBulltePosX, m_nPlayerBulltePosX + nWidht);
pObjp->setMonsterRECT(m_nMonsterPosY, m_nMonsterPosY + nHeight, m_nMonsterPosX, m_nMonsterPosX + nWidht);
if (pObjp->getPlayerBulletRECT())
{
m_cObjMgr.m_listPlayerBullet.erase(itorP++);
}
else
itorP++;
}
리스트로 하나하나 입력 받아서 충돌시에 총돌한 리스트를 지우는 로직인데요.
제가 뭘 잘못한건지 총알을 발사를 하면 가장 마지막으로 발사한 총알만 충돌 처리가 되네요.
총알을 두번 쏘면 두번째 총알만 충돌 처리가 되요..
고칠 수 있는 방법좀 알 수 있을까요?