🖥️ WorldToScreen

What is it?

Converts world coordinates (for example, an object's position or a hit point) into screen coordinates, useful for drawing UI elements or effects on the canvas.

📖 Syntax

WorldToScreen(x, y)

📦 Returns

{
  x: screenValueX,
  y: screenValueY
}

✅ Example

// Convert the player's world position to screen position to draw text
const pos = WorldToScreen(player.x, player.y);
drawText("Player", pos.x, pos.y - 20);

📌 Notes

- It is the inverse operation of ScreenToWorld().
- Very useful for showing indicators, labels or HUDs over world objects.