添加了获得公交车在画布中位置的函数

This commit is contained in:
2022-06-27 11:00:00 +08:00
parent 6c9328d783
commit 50aa9d9c6a
2 changed files with 64 additions and 1 deletions

View File

@@ -25,7 +25,7 @@ SceneManager::~SceneManager()
void SceneManager::SetStopScene(int node_number)
{
// 先清除以下屏幕
// 先清除屏幕
ClearScene();
stop_node_number = node_number;
@@ -117,3 +117,43 @@ void PosPair::AddLength(int length)
pos_x = stop_begin_x + distance;
}
}
int PosPair::GetBusPosX() const
{
int result;
if(pos_x <= stop_begin_x)
{
result = stop_begin_x - stop_bus_distance;
}
else if(pos_x >= stop_begin_x + stop_rail_width)
{
result = pos_x + stop_bus_distance;
}
else
{
result = pos_x;
}
return result;
}
int PosPair::GetBusPosY() const
{
int result;
if(pos_y <= stop_begin_y)
{
result = stop_begin_y - stop_bus_distance;
}
else if(pos_y >= stop_begin_y + stop_rail_width)
{
result = pos_y + stop_bus_distance;
}
else
{
result = pos_y;
}
return result;
}