mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
use index 5 for a shortcut hookthrough tile
This commit is contained in:
parent
e5f6356899
commit
ba60cf509a
|
@ -110,7 +110,7 @@ void CCollision::Init(class CLayers *pLayers)
|
|||
{
|
||||
// remove unused tiles from front layer
|
||||
Index = m_pFront[i].m_Index;
|
||||
if(Index <= TILE_NPH_START && !(Index == TILE_DEATH || Index == TILE_NOLASER || Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || (Index >= TILE_CP && Index <= TILE_THROUGH_DIR) || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
|
||||
if(Index <= TILE_NPH_START && !(Index == TILE_DEATH || (Index >= TILE_NOLASER && Index <= TILE_THROUGH) || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || (Index >= TILE_CP && Index <= TILE_THROUGH_DIR) || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
|
||||
m_pFront[i].m_Index = 0;
|
||||
}
|
||||
// remove unused tiles from game layer
|
||||
|
@ -425,7 +425,7 @@ int CCollision::IsSolid(int x, int y)
|
|||
bool CCollision::IsThrough(int x, int y, int xoff, int yoff, vec2 pos0, vec2 pos1)
|
||||
{
|
||||
int pos = GetPureMapIndex(x, y);
|
||||
if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_ALL)
|
||||
if(m_pFront && (m_pFront[pos].m_Index == TILE_THROUGH_ALL || m_pFront[pos].m_Index == TILE_THROUGH_CUT))
|
||||
return true;
|
||||
if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && (
|
||||
(m_pFront[pos].m_Flags == ROTATION_0 && pos0.y > pos1.y) ||
|
||||
|
|
|
@ -507,6 +507,9 @@ public:
|
|||
CLayerTiles(int w, int h);
|
||||
~CLayerTiles();
|
||||
|
||||
virtual CTile GetTile(int x, int y, bool force=false);
|
||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void Shift(int Direction);
|
||||
|
||||
|
@ -590,6 +593,9 @@ public:
|
|||
CLayerGame(int w, int h);
|
||||
~CLayerGame();
|
||||
|
||||
virtual CTile GetTile(int x, int y, bool force=false);
|
||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
||||
|
||||
virtual int RenderProperties(CUIRect *pToolbox);
|
||||
};
|
||||
|
||||
|
@ -1077,6 +1083,8 @@ public:
|
|||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void Shift(int Direction);
|
||||
virtual CTile GetTile(int x, int y, bool force=false);
|
||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,38 @@ CLayerGame::~CLayerGame()
|
|||
{
|
||||
}
|
||||
|
||||
CTile CLayerGame::GetTile(int x, int y, bool force)
|
||||
{
|
||||
if(!force && m_pEditor->m_Map.m_pFrontLayer && GetTile(x, y, true).m_Index == TILE_NOHOOK && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT)
|
||||
{
|
||||
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
|
||||
return throughcut;
|
||||
} else {
|
||||
return m_pTiles[y*m_Width+x];
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerGame::SetTile(int x, int y, CTile tile, bool force)
|
||||
{
|
||||
if(!force && tile.m_Index == TILE_THROUGH_CUT) {
|
||||
if(!m_pEditor->m_Map.m_pFrontLayer) {
|
||||
CLayer *l = new CLayerFront(m_Width, m_Height);
|
||||
m_pEditor->m_Map.MakeFrontLayer(l);
|
||||
m_pEditor->m_Map.m_lGroups[m_pEditor->m_SelectedGroup]->AddLayer(l);
|
||||
}
|
||||
CTile nohook = {TILE_NOHOOK, 0, 0, 0};
|
||||
SetTile(x, y, nohook, true);
|
||||
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
|
||||
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, throughcut, true);
|
||||
} else {
|
||||
if(!force && m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
|
||||
CTile air = {TILE_AIR, 0, 0, 0};
|
||||
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, air, true);
|
||||
}
|
||||
m_pTiles[y*m_Width+x] = tile;
|
||||
}
|
||||
}
|
||||
|
||||
int CLayerGame::RenderProperties(CUIRect *pToolbox)
|
||||
{
|
||||
int r = CLayerTiles::RenderProperties(pToolbox);
|
||||
|
|
|
@ -46,6 +46,16 @@ CLayerTiles::~CLayerTiles()
|
|||
delete [] m_pTiles;
|
||||
}
|
||||
|
||||
CTile CLayerTiles::GetTile(int x, int y, bool force)
|
||||
{
|
||||
return m_pTiles[y*m_Width+x];
|
||||
}
|
||||
|
||||
void CLayerTiles::SetTile(int x, int y, CTile tile, bool force)
|
||||
{
|
||||
m_pTiles[y*m_Width+x] = tile;
|
||||
}
|
||||
|
||||
void CLayerTiles::PrepareForSave()
|
||||
{
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
|
@ -175,7 +185,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
|
||||
// copy the tele data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
|
@ -202,7 +212,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
|
||||
// copy the speedup data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
|
@ -235,7 +245,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
|
||||
// copy the switch data
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
|
@ -255,7 +265,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
}
|
||||
|
||||
else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pTuneLayer)
|
||||
{
|
||||
{
|
||||
CLayerTune *pGrabbed = new CLayerTune(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
|
@ -264,52 +274,52 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
|
||||
// copy the tiles
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
{
|
||||
pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x] = ((CLayerTune*)this)->m_pTuneTile[(r.y+y)*m_Width+(r.x+x)];
|
||||
if(pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x].m_Type == TILE_TUNE1)
|
||||
{
|
||||
m_pEditor->m_TuningNum = pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x].m_Number;
|
||||
}
|
||||
}
|
||||
pGrabbed->m_TuningNumber = m_pEditor->m_TuningNum;
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
|
||||
}
|
||||
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
{
|
||||
pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x] = ((CLayerTune*)this)->m_pTuneTile[(r.y+y)*m_Width+(r.x+x)];
|
||||
if(pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x].m_Type == TILE_TUNE1)
|
||||
{
|
||||
m_pEditor->m_TuningNum = pGrabbed->m_pTuneTile[y*pGrabbed->m_Width+x].m_Number;
|
||||
}
|
||||
}
|
||||
pGrabbed->m_TuningNumber = m_pEditor->m_TuningNum;
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
|
||||
}
|
||||
else if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pFrontLayer)
|
||||
{
|
||||
CLayerFront *pGrabbed = new CLayerFront(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
CLayerFront *pGrabbed = new CLayerFront(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
|
||||
}
|
||||
else
|
||||
{
|
||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
|
||||
// copy the tiles
|
||||
for(int y = 0; y < r.h; y++)
|
||||
for(int x = 0; x < r.w; x++)
|
||||
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
|
||||
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
|
||||
}
|
||||
|
||||
|
@ -343,7 +353,7 @@ void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
|||
if(Empty)
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 1;
|
||||
else
|
||||
m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
|
||||
SetTile(fx, fy, pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)]);
|
||||
}
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
|
@ -367,7 +377,7 @@ void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
|
||||
SetTile(fx, fy, l->m_pTiles[y*l->m_Width+x]);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -1274,6 +1284,22 @@ CLayerFront::CLayerFront(int w, int h)
|
|||
m_Front = 1;
|
||||
}
|
||||
|
||||
CTile CLayerFront::GetTile(int x, int y, bool force)
|
||||
{
|
||||
if(!force && GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
|
||||
CTile air = {TILE_AIR, 0, 0, 0};
|
||||
return air;
|
||||
} else {
|
||||
return m_pTiles[y*m_Width+x];
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerFront::SetTile(int x, int y, CTile tile, bool force)
|
||||
{
|
||||
if(force || GetTile(x, y, true).m_Index != TILE_THROUGH_CUT)
|
||||
m_pTiles[y*m_Width+x] = tile;
|
||||
}
|
||||
|
||||
void CLayerFront::Resize(int NewW, int NewH)
|
||||
{
|
||||
// resize tile data
|
||||
|
@ -1307,7 +1333,7 @@ void CLayerFront::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
|
||||
SetTile(fx, fy, l->m_pTiles[y*l->m_Width+x]);
|
||||
}
|
||||
m_pEditor->m_Map.m_Modified = true;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ enum
|
|||
TILE_DEATH,
|
||||
TILE_NOHOOK,
|
||||
TILE_NOLASER,
|
||||
TILE_THROUGH = 6,
|
||||
TILE_THROUGH_CUT,
|
||||
TILE_THROUGH,
|
||||
TILE_JUMP,
|
||||
TILE_FREEZE = 9,
|
||||
TILE_TELEINEVIL,
|
||||
|
|
Loading…
Reference in a new issue