Loading…
avirahmandev
Translation added |
|
avirahmandev
Contributor joined |
Contributor joined
2 months ago
|
None
String updated in the repository |
|
English | Indonesian | ||
---|---|---|---|
argument | argumen | Learn GDScript From Zero | |
function | fungsi | Learn GDScript From Zero |
In your projects, you will need to define your own variables.
Imagine that you need to track the player's health in your game.
They may start with [code]5[/code] health points. When taking a hit, the health should go down to [code]4[/code]. After another hit, it should be [code]3[/code]. And so on.
To keep track of that, you can create a variable named [code]health[/code] to which you add and subtract points.
The example below introduces the [code]print()[/code] function, which outputs its argument to the output box on the left.
Click the [i]run()[/i] button to instantly run the entire function, and click the [i]step[/i] button to execute lines of code one by one.
The [i]Debugger[/i] panel at the bottom shows the current value of the [code]health[/code] variable.
Dalam proyek Anda, Anda perlu mendefinisikan variabel Anda sendiri.
Bayangkan Anda perlu melacak kesehatan pemain di game Anda.
Mereka mungkin memulai dengan [kode]5[/kode] poin kesehatan. Saat terkena serangan, kesehatannya akan turun ke [kode]4[/kode]. Setelah pukulan lainnya, seharusnya menjadi [code]3[/code]. Dan seterusnya.
Untuk melacaknya, Anda dapat membuat variabel bernama [code]health[/code] yang Anda tambahkan dan kurangi poinnya.
Contoh di bawah memperkenalkan fungsi [code]print()[/code], yang mengeluarkan argumennya ke kotak keluaran di sebelah kiri.
Klik tombol [i]run()[/i] untuk menjalankan seluruh fungsi, dan klik tombol [i]step[/i] untuk mengeksekusi baris kode satu per satu.
Panel [i]Debugger[/i] di bagian bawah menunjukkan nilai variabel [code]health[/code] saat ini.