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 tutorial the first while loop starts with value of count 0 and ends with 4, which is less than the maximum value of 5, but it has looped 5 times.

The second while loop starts with 5 and ends with 0, which loops 6 times. And, the final count value after this while loop is -1.

Output Console

As for your practice, try changing the placement of count += 1 and count -= 1 by putting them above the print() function.

0 comments:

Post a Comment

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