You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description:
Creating a parameter list with undefined parameters messes with my brain
In my mind, this code should generate an error.
I really struggled with the idea that I could just put "length" as a parameter without having to define it.
Let's make our square drawing function more flexible
to include rectangles of varying sizes.
Your job is to code a function named
draw_rectangle () that takes two parameters: the
length and the he ight of the rectangle.
The turtle should face towards the right when
starting or completing a rectangle.
Note that we could still draw a square with
draw_rectangle () by having the length and
height equal the same value.
If this is related to the https://gdquest.itch.io/learn-godot-gdscript cute little turtle game:
Imagine you are creating tests for your function, you would want the parameters to accept any value within your definition. The goal of the tutorial is to abstract some of this away from the user. It doesn't really matter what length or height equal, just that its clear to the user it going to be an int. Rectangles [subsequently squares], have 4 - 90 degree angles and sides. func draw_rectangle() always needs to run turn_right(90) to accept to create the correct shape. Even if we abstracted func turn_right(angle) angle would always equal 90 to produce a 4 sided rectangle. It's more confusing this way, because the new student might ask "why is the angle abstracted?"
Now from a technical argument, func draw_rectangle() could actually draw any shape, but that's a bad habit I think the tutorial is guiding you away from by providing such assignments and definitions. I think this is some pythonic influence as well, because all the function really says is "I need to parameters to execute" there is no type hinting or assertion as far as we can see in the gamified interface.
Issue description:
Creating a parameter list with undefined parameters messes with my brain
In my mind, this code should generate an error.
I really struggled with the idea that I could just put "length" as a parameter without having to define it.
func draw_rectangle(length, height): move_forward(length) turn_right(90) move_forward(height) turn_right(90) move_forward(length) turn_right(90) move_forward(height) turn_right(90)
The text was updated successfully, but these errors were encountered: