Tutorial 1: Basic Numbers in GDScript

Numbers in GDScript
The image above shows an example code on how to solve the area of a circle using Godot script. You can download the source code here.

In the GDScript, you'll learn how to declare an integer, float and constant variables; the use of a hash symbol for remarks; utilizing the built-in function _ready() to generate results in the output console; using the print() function to print texts; converting any numbers to string with str() function; and, stepify() function used to reduce a float to 2 decimal places.

Below shows the answer in the Output console using the given radius of 3.

Godot Output Console

As for your practice, solve the area of a cone utilizing the techniques in this tutorial with the sqrt() function.

Related Posts:

  • Tutorial 8: Basic For Loop in GDScript GDScript of Basic For Loop In this example, it shows the basic uses of a for loop statement. One is to increment and the other decrements the value of 'n'. There are other usages but for now let's tackle the common ones. … Read More
  • Tutorial 10: Diamond Shapes using Loops in GDScriptextends Node2D # Draws a diamond with adjustable size func _ready(): # Try changing 6 with even integers from 4 to 26 diamond_for(6) diamond_while(6) func diamond_for(size: int): tri_for(size) #Upside T… Read More
  • Tutorial 7: Basic Match Statement in GDScript GDScript Match Statement The Godot match statement is the equivalent of switch statement in other programming languages. It's a cleaner way of handling conditional statements. If a match statement can handle my conditions… Read More
  • Tutorial 9: Basic While Loop in GDScript GDScript While Loop The GDScript above shows the basic uses of while loop to increment and decrement values. In this example the decrement operator -= is introduced. You can download the source code here. In this tutoria… Read More
  • Tutorial 11: Series 1 Exercise 1 in GDScriptextends Node2D const CURRENT_PRINCIPAL: float = 5678.9 const INTEREST_RATE: float = 0.03 const COMPOUND_PER_YEAR: int = 1 var years_to_grow: int = 50 var target_amount: int = 7000 func _ready(): plot_years(CURRENT_PRINCIPA… Read More

0 comments:

Post a Comment

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