Skip to content

Conversation

@jgbourque
Copy link
Contributor

Hoping to get some feedback on adding additional commenting within scripts for this learner content. The idea would be that for a learner who is new to all programming, but also wants to poke around and mod this particular script to change gameplay, some additional commentary might help them find or understand a little bit more of the overall script.

Just making this a draft to hear what others think.

The comments were generated using claude.ai through a series of prompts guiding it to expand the comments without cluttering the script at the same time.

Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I really dislike this commenting style:

	vel.y += grv * delta  # Apply gravity (delta makes movement consistent regardless of frame rate)

and the GDScript style guide broadly agrees with me:

Prefer writing comments on their own line as opposed to inline comments (comments written on the same line as code). Inline comments are best used for short comments, typically a few words at most.

I left a few examples of how I would adjust the comments inline.

return hit

func TryLoop(arg : String):
func TryLoop(arg : String): # Changes animations only if needed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TryLoop(arg : String): # Changes animations only if needed
## Start an animation if it is not already running
func TryLoop(arg : String):


func _ready() -> void:
var world_textures := ResourceFinder.load_world_assets(self, "Player")
@export var interactive := true # Makes this variable appear in the Inspector panel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is actively misleading. The comment refers to the @export annotation but I would read it as saying that the interactive property itself has something to do with the inspector panel.

@onready var NodeAnim := $AnimationPlayer # Controls animations

# Movement physics variables
var vel := Vector2.ZERO # Current velocity (speed and direction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When documenting variables and functions it is IMO preferable to use the ## documentation comment syntax:

Suggested change
var vel := Vector2.ZERO # Current velocity (speed and direction)
## Current velocity (speed and direction)
var vel := Vector2.ZERO

@manuq
Copy link
Contributor

manuq commented Mar 12, 2025

I agree with @wjt and the Godot style guide. Comments in their own line are more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants