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. You can download the source code here.
This example builds from the previous tutorials, and includes concepts from the previous lessons. If there are things here that are new to you, then I suggest studying the previous posts in Series 1 Tutorials.
Apart from the for loop examples, this tutorial introduces the use of increment operators like += .
The first for loop starts from 0 and ends with 2 (range(3)), the second does the opposite, which starts from 3 and decrements till it ends with 1 (range(3, 0, -1)), the last one does a similar thing like the first one, but for the sake of implementations let's use (range(0, 3, 1)). Each for loop calls a function prnt() to print the number of loops and 'n' values.
Output Console |
As for your practics, try changing the range values and see what happens.
0 comments:
Post a Comment