-
Notifications
You must be signed in to change notification settings - Fork 19
adding additional comments to the player script to give more context … #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
wjt
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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:
| var vel := Vector2.ZERO # Current velocity (speed and direction) | |
| ## Current velocity (speed and direction) | |
| var vel := Vector2.ZERO |
|
I agree with @wjt and the Godot style guide. Comments in their own line are more readable. |
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.