mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 17:44:18 +00:00
Implementing the FrontLayer
Also trimmed the trailings Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
8450116185
commit
6bb5fcf316
|
@ -21,10 +21,6 @@ CCollision::CCollision()
|
||||||
m_pSpeedup = 0;
|
m_pSpeedup = 0;
|
||||||
m_pFront = 0;
|
m_pFront = 0;
|
||||||
}
|
}
|
||||||
int CCollision::IsSolid(int x, int y)
|
|
||||||
{
|
|
||||||
return (GetTile(x,y)&COLFLAG_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCollision::Init(class CLayers *pLayers)
|
void CCollision::Init(class CLayers *pLayers)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +110,8 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
|
||||||
|
|
||||||
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
||||||
|
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
||||||
|
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
||||||
{
|
{
|
||||||
|
@ -134,6 +132,8 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
|
||||||
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
|
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
|
||||||
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
||||||
|
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
||||||
|
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
||||||
{
|
{
|
||||||
|
@ -159,6 +159,13 @@ int CCollision::GetCollisionDDRace(int Index)
|
||||||
return 0;
|
return 0;
|
||||||
return m_pTiles[Index].m_Index;
|
return m_pTiles[Index].m_Index;
|
||||||
}
|
}
|
||||||
|
int CCollision::GetCollisionDDRace2(int Index)
|
||||||
|
{
|
||||||
|
/*dbg_msg("GetCollisionDDRace2","m_pFront[%d].m_Index = %d",Index,m_pFront[Index].m_Index);//Remove*/
|
||||||
|
if(Index < 0)
|
||||||
|
return 0;
|
||||||
|
return m_pFront[Index].m_Index;
|
||||||
|
}
|
||||||
|
|
||||||
int CCollision::GetTile(int x, int y)
|
int CCollision::GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
|
@ -173,9 +180,9 @@ int CCollision::GetTile(int x, int y)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int CCollision::Entitiy(int x, int y)
|
int CCollision::Entity(int x, int y, bool Front)
|
||||||
{
|
{
|
||||||
int Index = m_pTiles[y*m_Width+x].m_Index;
|
int Index = Front?m_pFront[y*m_Width+x].m_Index:m_pTiles[y*m_Width+x].m_Index;
|
||||||
return Index-ENTITY_OFFSET;
|
return Index-ENTITY_OFFSET;
|
||||||
}
|
}
|
||||||
void CCollision::SetCollisionAt(float x, float y, int flag)
|
void CCollision::SetCollisionAt(float x, float y, int flag)
|
||||||
|
@ -379,6 +386,11 @@ bool CCollision::TestBox(vec2 Pos, vec2 Size)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CCollision::IsSolid(int x, int y)
|
||||||
|
{
|
||||||
|
return (GetTile(x,y)&COLFLAG_SOLID);
|
||||||
|
}
|
||||||
|
|
||||||
int CCollision::IsNoLaser(int x, int y)
|
int CCollision::IsNoLaser(int x, int y)
|
||||||
{
|
{
|
||||||
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
|
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
|
||||||
|
@ -444,10 +456,11 @@ bool CCollision::IsFront(int x, int y)
|
||||||
|
|
||||||
if(m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index > 0)
|
if(m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index > 0)
|
||||||
{
|
{
|
||||||
dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
/*dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
/*else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCollision::IsCp(int x, int y)
|
int CCollision::IsCp(int x, int y)
|
||||||
|
|
|
@ -34,11 +34,12 @@ public:
|
||||||
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
||||||
bool TestBox(vec2 Pos, vec2 Size);
|
bool TestBox(vec2 Pos, vec2 Size);
|
||||||
int GetTile(int x, int y);
|
int GetTile(int x, int y);
|
||||||
int Entitiy(int x, int y);
|
int Entity(int x, int y, bool Front);
|
||||||
//DDRace
|
//DDRace
|
||||||
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
||||||
vec2 GetPos(int Index);
|
vec2 GetPos(int Index);
|
||||||
int GetCollisionDDRace(int Index);
|
int GetCollisionDDRace(int Index);
|
||||||
|
int GetCollisionDDRace2(int Index);
|
||||||
int IsTeleport(int x, int y);
|
int IsTeleport(int x, int y);
|
||||||
int IsCheckpoint(int Index);
|
int IsCheckpoint(int Index);
|
||||||
bool IsSpeedup(int x, int y);
|
bool IsSpeedup(int x, int y);
|
||||||
|
|
|
@ -558,7 +558,8 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
|
||||||
void CCharacter::Tick()
|
void CCharacter::Tick()
|
||||||
{
|
{
|
||||||
int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos);
|
int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos);
|
||||||
int TileIndex = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
|
int TileIndex1 = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
|
||||||
|
int TileIndex2 = GameServer()->Collision()->GetCollisionDDRace2(MapIndex);
|
||||||
if(m_RaceState == RACE_PAUSE) {
|
if(m_RaceState == RACE_PAUSE) {
|
||||||
m_Input.m_Direction = 0;
|
m_Input.m_Direction = 0;
|
||||||
m_Input.m_Jump = 0;
|
m_Input.m_Jump = 0;
|
||||||
|
@ -600,7 +601,7 @@ void CCharacter::Tick()
|
||||||
m_Core.m_HookTick = 0;
|
m_Core.m_HookTick = 0;
|
||||||
if (m_Super && m_Core.m_Jumped > 1)
|
if (m_Super && m_Core.m_Jumped > 1)
|
||||||
m_Core.m_Jumped = 1;
|
m_Core.m_Jumped = 1;
|
||||||
/*dbg_msg("character","TileIndex%d",TileIndex); //REMOVE*/
|
/*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/
|
||||||
//DDRace
|
//DDRace
|
||||||
char aBuftime[128];
|
char aBuftime[128];
|
||||||
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
|
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
|
||||||
|
@ -619,13 +620,13 @@ void CCharacter::Tick()
|
||||||
}
|
}
|
||||||
m_RefreshTime = Server()->Tick();
|
m_RefreshTime = Server()->Tick();
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_BEGIN) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
|
if(((TileIndex1 == TILE_BEGIN) || (TileIndex2 == TILE_BEGIN)) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
|
||||||
{
|
{
|
||||||
m_StartTime = Server()->Tick();
|
m_StartTime = Server()->Tick();
|
||||||
m_RefreshTime = Server()->Tick();
|
m_RefreshTime = Server()->Tick();
|
||||||
m_RaceState = RACE_STARTED;
|
m_RaceState = RACE_STARTED;
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_END) && m_RaceState == RACE_STARTED)
|
if(((TileIndex1 == TILE_END) || (TileIndex2 == TILE_END)) && m_RaceState == RACE_STARTED)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
if ((int)time / 60 != 0)
|
if ((int)time / 60 != 0)
|
||||||
|
@ -649,60 +650,103 @@ void CCharacter::Tick()
|
||||||
if(strncmp(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
|
if(strncmp(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
|
||||||
((CGameControllerDDRace*)GameServer()->m_pController)->m_Score.ParsePlayer(Server()->ClientName(m_pPlayer->GetCID()), (float)time);
|
((CGameControllerDDRace*)GameServer()->m_pController)->m_Score.ParsePlayer(Server()->ClientName(m_pPlayer->GetCID()), (float)time);
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_FREEZE) && !m_Super)
|
if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super)
|
||||||
{
|
{
|
||||||
Freeze(Server()->TickSpeed()*3);
|
Freeze(Server()->TickSpeed()*3);
|
||||||
}
|
}
|
||||||
else if(TileIndex == TILE_UNFREEZE)
|
else if((TileIndex1 == TILE_UNFREEZE) || (TileIndex2 == TILE_UNFREEZE))
|
||||||
{
|
{
|
||||||
UnFreeze();
|
UnFreeze();
|
||||||
}
|
}
|
||||||
else if ((TileIndex >= TILE_BOOST_L && TileIndex <= TILE_BOOST_U) || (TileIndex >= TILE_BOOST_L2 && TileIndex <= TILE_BOOST_U2))
|
if (((TileIndex1 >= TILE_BOOST_L && TileIndex1 <= TILE_BOOST_U) || (TileIndex1 >= TILE_BOOST_L2 && TileIndex1 <= TILE_BOOST_U2)))
|
||||||
{
|
{
|
||||||
int booster = TileIndex;
|
int booster = TileIndex1;
|
||||||
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPL)
|
if ((TileIndex2 >= TILE_BOOST_L && TileIndex2 <= TILE_BOOST_U) || (TileIndex2 >= TILE_BOOST_L2 && TileIndex2 <= TILE_BOOST_U2))
|
||||||
|
{
|
||||||
|
int booster = TileIndex2;
|
||||||
|
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
||||||
|
}
|
||||||
|
if(TileIndex1 == TILE_STOPL)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.x > 0)
|
if(m_Core.m_Vel.x > 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).x < (int)m_Core.m_Pos.x)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).x < (int)m_Core.m_Pos.x)
|
||||||
m_Core.m_Pos.x = m_PrevPos.x;
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
m_Core.m_Vel.x = 0;
|
m_Core.m_Vel.x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPR)
|
if(TileIndex2 == TILE_STOPL)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.x > 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).x < (int)m_Core.m_Pos.x)
|
||||||
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
|
m_Core.m_Vel.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex1 == TILE_STOPR)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.x < 0)
|
if(m_Core.m_Vel.x < 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).x > (int)m_Core.m_Pos.x)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).x > (int)m_Core.m_Pos.x)
|
||||||
m_Core.m_Pos.x = m_PrevPos.x;
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
m_Core.m_Vel.x = 0;
|
m_Core.m_Vel.x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPB)
|
if(TileIndex1 == TILE_STOPB)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.y < 0)
|
if(m_Core.m_Vel.y < 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).y > (int)m_Core.m_Pos.y)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).y > (int)m_Core.m_Pos.y)
|
||||||
m_Core.m_Pos.y = m_PrevPos.y;
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
m_Core.m_Vel.y = 0;
|
m_Core.m_Vel.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPT)
|
if(TileIndex1 == TILE_STOPT)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.y > 0)
|
if(m_Core.m_Vel.y > 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).y < (int)m_Core.m_Pos.y)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).y < (int)m_Core.m_Pos.y)
|
||||||
m_Core.m_Pos.y = m_PrevPos.y;
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
||||||
m_Core.m_Jumped = m_Jumped;
|
m_Core.m_Jumped = m_Jumped;
|
||||||
m_Core.m_Vel.y = 0;
|
m_Core.m_Vel.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
if(TileIndex2 == TILE_STOPR)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.x < 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).x > (int)m_Core.m_Pos.x)
|
||||||
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
|
m_Core.m_Vel.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex2 == TILE_STOPB)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.y < 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).y > (int)m_Core.m_Pos.y)
|
||||||
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
|
m_Core.m_Vel.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex2 == TILE_STOPT)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.y > 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).y < (int)m_Core.m_Pos.y)
|
||||||
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
|
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
||||||
|
m_Core.m_Jumped = m_Jumped;
|
||||||
|
m_Core.m_Vel.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(GameServer()->Collision()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
||||||
;
|
;
|
||||||
else if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
||||||
{
|
{
|
||||||
vec2 Direction;
|
vec2 Direction;
|
||||||
int Force;
|
int Force;
|
||||||
|
@ -710,7 +754,7 @@ void CCharacter::Tick()
|
||||||
|
|
||||||
m_Core.m_Vel += Direction*Force;
|
m_Core.m_Vel += Direction*Force;
|
||||||
}
|
}
|
||||||
else if(z)
|
if(z)
|
||||||
{
|
{
|
||||||
m_Core.m_HookedPlayer = -1;
|
m_Core.m_HookedPlayer = -1;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
|
|
|
@ -1571,18 +1571,29 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
||||||
// create all entities from the game layer
|
// create all entities from the game layer
|
||||||
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
|
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
|
||||||
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
|
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
|
||||||
|
//CMapItemLayerTilemap *pFrontMap = m_Layers.FrontLayer(); not needed game layer and front layer are always the same size
|
||||||
|
CTile *pFront=0;
|
||||||
|
if (m_Layers.FrontLayer())
|
||||||
|
pFront = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Front);
|
||||||
|
|
||||||
//windows usually crshes here
|
|
||||||
for(int y = 0; y < pTileMap->m_Height; y++)
|
for(int y = 0; y < pTileMap->m_Height; y++)
|
||||||
{
|
{
|
||||||
for(int x = 0; x < pTileMap->m_Width; x++)
|
for(int x = 0; x < pTileMap->m_Width; x++)
|
||||||
{
|
{
|
||||||
int Index = pTiles[y*pTileMap->m_Width+x].m_Index;
|
int Index = pTiles[y*pTileMap->m_Width+x].m_Index;
|
||||||
|
|
||||||
if(Index >= ENTITY_OFFSET)
|
if(Index >= ENTITY_OFFSET)
|
||||||
{
|
{
|
||||||
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
||||||
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos);
|
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos,false);
|
||||||
|
}
|
||||||
|
if (pFront)
|
||||||
|
{
|
||||||
|
int FIndex = pFront[y*pTileMap->m_Width+x].m_Index;
|
||||||
|
if(FIndex >= ENTITY_OFFSET)
|
||||||
|
{
|
||||||
|
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
||||||
|
m_pController->OnEntity(FIndex-ENTITY_OFFSET, Pos,true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,23 +117,26 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
|
||||||
return Eval.m_Got;
|
return Eval.m_Got;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IGameController::OnEntity(int Index, vec2 Pos)
|
bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
|
||||||
{
|
{
|
||||||
|
//if (Index<0)
|
||||||
|
//return false;
|
||||||
|
dbg_msg("OnEntity","Index=%d, Pos=(%d,%d), Front=%d",Index,Pos.x,Pos.y,Front);//Remove*/
|
||||||
int Type = -1;
|
int Type = -1;
|
||||||
int SubType = 0;
|
int SubType = 0;
|
||||||
int x,y;
|
int x,y;
|
||||||
x=(Pos.x-16.0f)/32.0f;
|
x=(Pos.x-16.0f)/32.0f;
|
||||||
y=(Pos.y-16.0f)/32.0f;
|
y=(Pos.y-16.0f)/32.0f;
|
||||||
dbg_msg("OnEntity","Pos(%d,%d)",x,y);
|
/*dbg_msg("OnEntity","Pos(%d,%d)",x,y);//Remove*/
|
||||||
int sides[8];
|
int sides[8];
|
||||||
sides[0]=GameServer()->Collision()->Entitiy(x,y+1);
|
sides[0]=GameServer()->Collision()->Entity(x,y+1, Front);
|
||||||
sides[1]=GameServer()->Collision()->Entitiy(x+1,y+1);
|
sides[1]=GameServer()->Collision()->Entity(x+1,y+1, Front);
|
||||||
sides[2]=GameServer()->Collision()->Entitiy(x+1,y);
|
sides[2]=GameServer()->Collision()->Entity(x+1,y, Front);
|
||||||
sides[3]=GameServer()->Collision()->Entitiy(x+1,y-1);
|
sides[3]=GameServer()->Collision()->Entity(x+1,y-1, Front);
|
||||||
sides[4]=GameServer()->Collision()->Entitiy(x,y-1);
|
sides[4]=GameServer()->Collision()->Entity(x,y-1, Front);
|
||||||
sides[5]=GameServer()->Collision()->Entitiy(x-1,y-1);
|
sides[5]=GameServer()->Collision()->Entity(x-1,y-1, Front);
|
||||||
sides[6]=GameServer()->Collision()->Entitiy(x-1,y);
|
sides[6]=GameServer()->Collision()->Entity(x-1,y, Front);
|
||||||
sides[7]=GameServer()->Collision()->Entitiy(x-1,y+1);
|
sides[7]=GameServer()->Collision()->Entity(x-1,y+1, Front);
|
||||||
|
|
||||||
|
|
||||||
if(Index == ENTITY_SPAWN)
|
if(Index == ENTITY_SPAWN)
|
||||||
|
@ -152,7 +155,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
CDoor * door = new CDoor(&GameServer()->m_World, Pos, pi/4*i, 32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, false);
|
CDoor * door = new CDoor(&GameServer()->m_World, Pos, pi/4*i, 32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, false);
|
||||||
//for (int j = 0; j < 8; j++)
|
//for (int j = 0; j < 8; j++)
|
||||||
// if (j != i)
|
// if (j != i)
|
||||||
Connector(vec2(x, y), door);
|
Connector(vec2(x, y), door, Front);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,14 +232,14 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
|
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
|
||||||
{
|
{
|
||||||
int sides2[8];
|
int sides2[8];
|
||||||
sides2[0]=GameServer()->Collision()->Entitiy(x,y+2);
|
sides2[0]=GameServer()->Collision()->Entity(x,y+2, Front);
|
||||||
sides2[1]=GameServer()->Collision()->Entitiy(x+2,y+2);
|
sides2[1]=GameServer()->Collision()->Entity(x+2,y+2, Front);
|
||||||
sides2[2]=GameServer()->Collision()->Entitiy(x+2,y);
|
sides2[2]=GameServer()->Collision()->Entity(x+2,y, Front);
|
||||||
sides2[3]=GameServer()->Collision()->Entitiy(x+2,y-2);
|
sides2[3]=GameServer()->Collision()->Entity(x+2,y-2, Front);
|
||||||
sides2[4]=GameServer()->Collision()->Entitiy(x,y-2);
|
sides2[4]=GameServer()->Collision()->Entity(x,y-2, Front);
|
||||||
sides2[5]=GameServer()->Collision()->Entitiy(x-2,y-2);
|
sides2[5]=GameServer()->Collision()->Entity(x-2,y-2, Front);
|
||||||
sides2[6]=GameServer()->Collision()->Entitiy(x-2,y);
|
sides2[6]=GameServer()->Collision()->Entity(x-2,y, Front);
|
||||||
sides2[7]=GameServer()->Collision()->Entitiy(x-2,y+2);
|
sides2[7]=GameServer()->Collision()->Entity(x-2,y+2, Front);
|
||||||
|
|
||||||
float ang_speed;
|
float ang_speed;
|
||||||
int ind=Index-ENTITY_LASER_STOP;
|
int ind=Index-ENTITY_LASER_STOP;
|
||||||
|
@ -322,21 +325,21 @@ vec2 GetSidePos(int side) {
|
||||||
return vec2(0, 0);
|
return vec2(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGameController::Connector(vec2 Pos, CDoor* Door) {
|
void IGameController::Connector(vec2 Pos, CDoor* Door, bool Front) {
|
||||||
int sides[8];
|
int sides[8];
|
||||||
sides[0] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y + 1);
|
sides[0] = GameServer()->Collision()->Entity(Pos.x, Pos.y + 1, Front);
|
||||||
sides[1] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y + 1);
|
sides[1] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y + 1, Front);
|
||||||
sides[2] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y);
|
sides[2] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y, Front);
|
||||||
sides[3] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y - 1);
|
sides[3] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y - 1, Front);
|
||||||
sides[4] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y - 1);
|
sides[4] = GameServer()->Collision()->Entity(Pos.x, Pos.y - 1, Front);
|
||||||
sides[5] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y - 1);
|
sides[5] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y - 1, Front);
|
||||||
sides[6] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y);
|
sides[6] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y, Front);
|
||||||
sides[7] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y + 1);
|
sides[7] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y + 1, Front);
|
||||||
for (int i=0;i<8;i++)
|
for (int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
vec2 shift = GetSidePos(i);
|
vec2 shift = GetSidePos(i);
|
||||||
if (sides[i]==ENTITY_CONNECTOR_D+(i+4) % 8)
|
if (sides[i]==ENTITY_CONNECTOR_D+(i+4) % 8)
|
||||||
Connector(Pos + shift, Door);
|
Connector(Pos + shift, Door, Front);
|
||||||
else if(sides[i]==ENTITY_TRIGGER)
|
else if(sides[i]==ENTITY_TRIGGER)
|
||||||
{
|
{
|
||||||
vec2 pos((Pos.x + shift.x)*32.0f + 16.0f, (Pos.y + shift.y)*32.0f + 16.0f);
|
vec2 pos((Pos.x + shift.x)*32.0f + 16.0f, (Pos.y + shift.y)*32.0f + 16.0f);
|
||||||
|
|
|
@ -101,9 +101,9 @@ public:
|
||||||
Returns:
|
Returns:
|
||||||
bool?
|
bool?
|
||||||
*/
|
*/
|
||||||
virtual bool OnEntity(int Index, vec2 Pos);
|
virtual bool OnEntity(int Index, vec2 Pos, bool Front);
|
||||||
|
|
||||||
virtual void Connector(vec2 Pos, CDoor* Door);
|
virtual void Connector(vec2 Pos, CDoor* Door, bool Front);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: on_CCharacter_spawn
|
Function: on_CCharacter_spawn
|
||||||
|
|
Loading…
Reference in a new issue