mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Added Max Speed
Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
f4082adf50
commit
a02bceafed
|
@ -369,6 +369,7 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedup, int w, int h, float
|
|||
int c = mx + my*w;
|
||||
|
||||
int Force = (int)pSpeedup[c].m_Force;
|
||||
int MaxSpeed = (int)pSpeedup[c].m_MaxSpeed;
|
||||
if(Force)
|
||||
{
|
||||
// draw arrow
|
||||
|
@ -385,6 +386,11 @@ void CRenderTools::RenderSpeedupmap(CSpeedupTile *pSpeedup, int w, int h, float
|
|||
char aBuf[16];
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Force);
|
||||
UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1);
|
||||
if(MaxSpeed)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
|
||||
UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -565,13 +565,15 @@ int CCollision::IsSpeedup(int Index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CCollision::GetSpeedup(int Index, vec2 *Dir, int *Force)
|
||||
void CCollision::GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed)
|
||||
{
|
||||
if(Index < 0)
|
||||
return;
|
||||
vec2 Direction = vec2(1, 0);
|
||||
float Angle = m_pSpeedup[Index].m_Angle * (3.14159265f/180.0f);
|
||||
*Force = m_pSpeedup[Index].m_Force;
|
||||
if(MaxSpeed)
|
||||
*MaxSpeed = m_pSpeedup[Index].m_MaxSpeed;
|
||||
|
||||
vec2 TmpDir;
|
||||
TmpDir.x = (Direction.x*cos(Angle)) - (Direction.y*sin(Angle));
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
int IsEvilTeleport(int Index);
|
||||
//int IsCheckpoint(int Index);
|
||||
int IsSpeedup(int Index);
|
||||
void GetSpeedup(int Index, vec2 *Dir, int *Force);
|
||||
void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed);
|
||||
|
||||
int IsSolid(int x, int y);
|
||||
int IsThrough(int x, int y);
|
||||
|
|
|
@ -875,7 +875,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
|
|||
if(DoButton_Ex(&s_SpeedupButton, "Speedup", (pS && pS->m_Speedup)?0:-1, &Button, 0, "Speedup", CUI::CORNER_ALL))
|
||||
{
|
||||
static int s_SpeedupPopupId = 0;
|
||||
UiInvokePopupMenu(&s_SpeedupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 43, PopupSpeedup);
|
||||
UiInvokePopupMenu(&s_SpeedupPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 53, PopupSpeedup);
|
||||
}
|
||||
|
||||
TB_Bottom.VSplitLeft(5.0f, &Button, &TB_Bottom);
|
||||
|
|
|
@ -568,6 +568,7 @@ public:
|
|||
m_SwitchNum = 1;
|
||||
|
||||
m_SpeedupForce = 50;
|
||||
m_SpeedupMaxSpeed = 0;
|
||||
m_SpeedupAngle = 0;
|
||||
}
|
||||
|
||||
|
@ -719,6 +720,7 @@ public:
|
|||
unsigned char m_TeleNum;
|
||||
|
||||
unsigned char m_SpeedupForce;
|
||||
unsigned char m_SpeedupMaxSpeed;
|
||||
short m_SpeedupAngle;
|
||||
|
||||
unsigned char m_SwitchNum;
|
||||
|
|
|
@ -190,6 +190,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
{
|
||||
m_pEditor->m_SpeedupAngle = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Angle;
|
||||
m_pEditor->m_SpeedupForce = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_Force;
|
||||
m_pEditor->m_SpeedupMaxSpeed = pGrabbed->m_pSpeedupTile[y*pGrabbed->m_Width+x].m_MaxSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -666,6 +667,7 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
if(m_pEditor->m_SpeedupForce)
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = m_pEditor->m_SpeedupForce;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = m_pEditor->m_SpeedupMaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = m_pEditor->m_SpeedupAngle;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Type = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = l->m_pTiles[y*l->m_Width+x].m_Index;
|
||||
|
@ -673,6 +675,7 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
|
@ -680,6 +683,7 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
|
@ -720,11 +724,13 @@ void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
|||
if(!pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Force && m_pEditor->m_SpeedupForce && m_pTiles[fy*m_Width+fx].m_Index > 0)
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = m_pEditor->m_SpeedupForce;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = m_pEditor->m_SpeedupMaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = m_pEditor->m_SpeedupAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Force;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_MaxSpeed;
|
||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = pLt->m_pSpeedupTile[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)].m_Angle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,8 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
|
|||
View.HSplitBottom(10.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewQuadLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add quads layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
//if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add quads layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewQuadLayerButton, Localize("Add Quads layer"), 0, &Button, 0, Localize("Creates a new quad layer")))
|
||||
{
|
||||
CLayer *l = new CLayerQuads;
|
||||
l->m_pEditor = pEditor;
|
||||
|
@ -179,7 +180,8 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
|
|||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
static int s_NewTileLayerButton = 0;
|
||||
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add tile layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
//if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add tile layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
if(pEditor->DoButton_Editor(&s_NewTileLayerButton, Localize("Add Tile layer"), 0, &Button, 0, Localize("Creates a new tile layer")))
|
||||
{
|
||||
CLayer *l = new CLayerTiles(50, 50);
|
||||
l->m_pEditor = pEditor;
|
||||
|
@ -577,12 +579,14 @@ int CEditor::PopupSpeedup(CEditor *pEditor, CUIRect View)
|
|||
enum
|
||||
{
|
||||
PROP_FORCE=0,
|
||||
PROP_MAXSPEED,
|
||||
PROP_ANGLE,
|
||||
NUM_PROPS,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
CProperty aProps[] = {
|
||||
{"Force", pEditor->m_SpeedupForce, PROPTYPE_INT_SCROLL, 0, 255},
|
||||
{"Max Speed", pEditor->m_SpeedupMaxSpeed, PROPTYPE_INT_SCROLL, 0, 255},
|
||||
{"Angle", pEditor->m_SpeedupAngle, PROPTYPE_INT_SCROLL, 0, 359},
|
||||
{0},
|
||||
};
|
||||
|
@ -590,9 +594,11 @@ int CEditor::PopupSpeedup(CEditor *pEditor, CUIRect View)
|
|||
static int s_aIds[NUM_PROPS] = {0};
|
||||
int NewVal = 0;
|
||||
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
|
||||
|
||||
|
||||
if(Prop == PROP_FORCE)
|
||||
pEditor->m_SpeedupForce = clamp(NewVal, 0, 255);
|
||||
if(Prop == PROP_MAXSPEED)
|
||||
pEditor->m_SpeedupMaxSpeed = clamp(NewVal, 0, 255);
|
||||
if(Prop == PROP_ANGLE)
|
||||
pEditor->m_SpeedupAngle = clamp(NewVal, 0, 359);
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ class CSpeedupTile
|
|||
{
|
||||
public:
|
||||
unsigned char m_Force;
|
||||
unsigned char m_MaxSpeed;
|
||||
unsigned char m_Type;
|
||||
short m_Angle;
|
||||
};
|
||||
|
|
|
@ -926,13 +926,19 @@ void CCharacter::Tick()
|
|||
m_Core.m_Vel.y += m_Core.m_Vel.y*1.1;
|
||||
}
|
||||
// handle speedup tiles
|
||||
//TODO:GFX Make MaxSpeed and Speed setters relative to Speedometer of the client
|
||||
if(GameServer()->Collision()->IsSpeedup(MapIndex) == TILE_BOOST)
|
||||
{
|
||||
vec2 Direction;
|
||||
int Force;
|
||||
GameServer()->Collision()->GetSpeedup(MapIndex, &Direction, &Force);
|
||||
|
||||
m_Core.m_Vel += Direction*Force;
|
||||
vec2 Direction, TempVel = m_Core.m_Vel;
|
||||
int Force, MaxSpeed = 0;
|
||||
GameServer()->Collision()->GetSpeedup(MapIndex, &Direction, &Force, &MaxSpeed);
|
||||
TempVel += Direction * Force;
|
||||
if(TempVel < Direction*(MaxSpeed) || !MaxSpeed)
|
||||
m_Core.m_Vel = TempVel;
|
||||
else
|
||||
{
|
||||
m_Core.m_Vel = Direction*MaxSpeed;
|
||||
}
|
||||
//dbg_msg("Direction","%f %f %f %f %f %f",Direction.x,Direction.y,(Direction*Force).x,(Direction*Force).y,m_Core.m_Vel.x,m_Core.m_Vel.y);
|
||||
|
||||
}
|
||||
|
@ -940,10 +946,8 @@ void CCharacter::Tick()
|
|||
{
|
||||
vec2 Direction;
|
||||
int Force;
|
||||
GameServer()->Collision()->GetSpeedup(MapIndex, &Direction, &Force);
|
||||
Force/=5;
|
||||
GameServer()->Collision()->GetSpeedup(MapIndex, &Direction, &Force, 0);
|
||||
m_Core.m_Vel = Direction*Force;
|
||||
m_Core.m_Vel+=Direction;
|
||||
//dbg_msg("Direction","%f %f %f %f %f %f",Direction.x,Direction.y,(Direction*Force).x,(Direction*Force).y,m_Core.m_Vel.x,m_Core.m_Vel.y);
|
||||
}
|
||||
m_LastBooster = MapIndex;
|
||||
|
|
Loading…
Reference in a new issue