Tutorial 2: Basic Variables in GDScript

GDScript with Specific Variable Types and Scoping

The image above shows a GDScript with basic variables declared with specific types, and with proper scoping. You can download the source code here.

In this example, we solve the area of a cone with the given variables. Each variable is declared with a specific type and properly positioned for global and local functions.

It uses similar functions based on the previous tutorial plus the latest sqrt() function. I suggest to do the previous tutorial before studying this one.

The answer of this example is printed in the Output console.

The Area of a Cone

Declaring variables with specific types and placing them in their proper scopes can minimize bugs and errors.

As for your practice, solve for the Area of a Sphere.

0 comments:

Post a Comment

© 2020 by Emman Lijesta, all rights reserved. Powered by Blogger.