Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 Once you start writing code, you will find out that parts of the code repeat themselves and this is 1
normal in programming. 2
In fact, it's the way it happens. When you find these patterns, 3
you can make them reusable by creating a function. 4
A function is a separate piece of code that can be called on demand by specifying its name in the execution. 5
Let's look at the code. 6
So here we have defined a function add(). 7
To create the new function, we need to use the operator func in GDScript and then the name of the 8
function. 9
And we do need to use the parenthesis, but they can be empty or we can specify additional parameters. 10
Don't forget to add the colons after each function implementation. In the function body 11
we can do something with the provided values and in this case we just add them. 12
And we used another operator called return, which will return the final value. 13
And this value can be used in the previous function that called this one. 14
In this case, I'll be saying adding one plus one and then calling this function. 15
This will add these two elements and will give the result to be printed in the console. 16
Keep in mind that now we can use this. 17
Add as many times as we like to add two values. 18
But this can be a move function. 19
This can be a fire projectile function. 20
This can be whatever you want. 21
There is also another type of function called recursive function, and the recursive function is just 22
like a regular function with the one spin that it calls itself in its own body. 23
As you might imagine, if you've seen the Inception movie, this can lead to infinite execution. 24
And we don't want that. 25
So remember, if you ever implement a recursive function, then you need to make sure that you have 26
something called the exit condition. 27
So the exit condition is usually an IF statement that checks a final condition to break this recursive 28
pattern. 29
This is important to prevent the function running indefinitely. 30
Recursive functions are useful in some particular algorithm implementations in this course.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.