// Code in the program is all lined up on the left...
using static SplashKitSDK.SplashKit;
const int BALL_RADIUS = 5;
const int PLAYER_RADIUS = 20;
// Used to calculate distance from player - mouse for
// Ball speed. speed = distance / DIST_TO_SPEED_RATIO.
const double DIST_TO_SPEED_RATIO = 30;
// as above for the line drawn to show direction of shot
const double DIST_LINE_RATIO = 10;
OpenWindow("Ball Throw", 800, 600);
double playerX = 400, playerY = 300;
// Code in this while loop is indented one tab
if (MouseClicked(MouseButton.LeftButton) && !ballFired)
// This is inside the if inside the while...
// So this is indented two tabs
ballXSpeed = (MouseX() - playerX) / DIST_TO_SPEED_RATIO;
ballYSpeed = (MouseY() - playerY) / DIST_TO_SPEED_RATIO;
// Here we are back in the while... indented one tab
// inside the if in the while... so two tabs
if (ballX + BALL_RADIUS < 0 || // off left
ballX - BALL_RADIUS > ScreenWidth() || // off right
ballY + BALL_RADIUS < 0 || // off top
ballY - BALL_RADIUS > ScreenHeight()
// Inside an if in an if in a while... so 3 tabs
// back just in the while... one tab
ClearScreen(ColorWhite());
FillCircle(ColorLightGreen(), playerX, playerY, PLAYER_RADIUS);
FillCircle(ColorBlack(), ballX, ballY, BALL_RADIUS);
// Show direction of travel
playerX + (MouseX() - playerX) / DIST_LINE_RATIO,
playerY + (MouseY() - playerY) / DIST_LINE_RATIO
// Back in the program - indented 0 tabs
WriteLine("I hope you enjoyed this program!");