Comments

Comments are notes in your source code that the compiler ignores. Use them to explain what your code does.

Single-line Comments

Start a comment with a single quote '. Everything after it on that line is ignored:

' This entire line is a comment
score = score + 10 ' this comment follows code on the same line

Good Commenting Practices

  1. Explain *why*, not *what*. The code itself shows what happens; a comment should explain the reasoning behind a decision.

    ' Subtract 1 from lives rather than setting to 0 so
    ' the death animation plays before the game over screen.
    lives = lives - 1
  2. Label sections of a longer program to help navigation:

    ' ---- Initialisation ----------------------------------------
    OpenWindow("My Game", 640, 480, false, true)

    ' ---- Main Loop ---------------------------------------------
    While NOT Key(K_ESCAPE)
    Update()
    Wend
  3. Disable code temporarily during debugging:

    ' DrawDebugOverlay()   ' uncomment to enable debug mode