Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DrawPlayer(OnlinePlayer player)
- {
- Vector2Int[] positions;
- byte[] jumpIndices;
- while ((positions = player.GetPositions()) != null)
- {
- jumpIndices = player.GetJumps();
- int jumpCounter = 0;
- for (int i = 1; i < positions.Length; ++i)
- {
- Vector2Int playerPosition = positions[i];
- Vector2Int playerLastPostion = positions[i - 1];
- DrawCircle(playerPosition, player.radius, player.Color);
- if ((jumpIndices.Length <= jumpCounter) || (!(jumpIndices[jumpCounter] == i) && playerLastPostion != playerPosition))
- {
- Vector2 directionVector = (player.position - player.lastPosition).normalized;
- Vector2 directionVectorTurnedLeft = new Vector2(Mathf.Cos(Mathf.Deg2Rad * 90) * directionVector.x - Mathf.Sin(Mathf.Deg2Rad * 90) * directionVector.y, Mathf.Sin(Mathf.Deg2Rad * 90) * directionVector.x + Mathf.Cos(Mathf.Deg2Rad * 90) * directionVector.y);
- Vector2 directionVectorTurnedRight = -1 * directionVectorTurnedLeft;
- Vector2 bottomLeftVertice = player.lastPosition + directionVectorTurnedLeft * player.radius;
- Vector2 bottomRightVertice = player.lastPosition + directionVectorTurnedRight * player.radius;
- Vector2 topLeftVertice = player.position + directionVectorTurnedLeft * player.radius;
- Vector2 topRightVertice = player.position + directionVectorTurnedRight * player.radius;
- DrawTriangle(VectorToInt(bottomLeftVertice), VectorToInt(bottomRightVertice), VectorToInt(topLeftVertice), player.Color);
- DrawTriangle(VectorToInt(topLeftVertice), VectorToInt(topRightVertice), VectorToInt(bottomRightVertice), player.Color);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement