• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

GDSCRIPT – Basic Godot Engine

AnonyViet by AnonyViet
February 1, 2023
in Tips
0

Hello friends! Continuing with the series The Ultimate Guide to Godot Engine. In today’s article, I will share with you about Godot Engine’s GDScript. The article consists of 2 parts: Basic GDScript and Object Oriented in GDScript. Before going to part 1, let’s start with a brief overview of GDScript!

Join the channel Telegram of the AnonyViet 👉 Link 👈

A SUMMARY OF GDSCRIPT

GDScript is a high-level programming language. It uses the same syntax as Python (indent-based blocks and many similar keywords). It is optimized and tightly integrated with the Godot Engine, allowing great flexibility for creating and integrating game content. If you are familiar with Python, coding with GDScript is extremely easy!

GDSCRIPT - Basic Godot Engine

GDSCRIPT BASIC FEMALE

1. Structuring a script.gd

GDSCRIPT BASIC INTRODUCTION

extends Node # Khai báo kế thừa. Phải kế thừa đúng tên lớp (tên Node) mà bạn sử dụng.

var a = 0 # Biến toàn cục

var b = 0 # Biến toàn cục

func _ready(): # Hàm

.     var c = a + b # Biến cục bộ

2. GDSCRIPT BASIC FEMALE

Main functions on GDScript

extends Node

func _init(): #Thực thi một lần duy nhất khi khởi chạy chương trình.

.     pass

func _ready(): #Thực thi một lần duy nhất khi Node sẵn sàng hoạt động.

.     pass

func _process(delta): #Hàm luôn thực thi lặp lại trong mỗi thời gian delta bằng nhau (không phùhợp cho các hoạt động vật lí)

.     pass

func _physics_process(delta): #Hàm thực thi lặp lại trong mỗi thời gian delta tăng dần (thích hợpcho hoạt động vật lí)

.     pass

Command to print Debug on the Console window

func _ready():

.     var a = 4

.     print(a);

.     print("\nHello World")

Output:

4

Hello Word

Data types, variables, constants and declarations

The data types on GDScript are similar to those in Python with two types: primitive types (without capital letters) and class types (with uppercase letters).

extends Node

#var <tên biến> : [kiểu dữ liệu] (có thể "=" để gán giá trị trực tiếp mà không cần khai báo kiểu dữ kiệu (ép kiểu ngầm))

var a = 4

var a: int = 4

var a

a = 4

#các kiểu khai báo trên là tương tự như nhau. Ngoài ra ta còn có thể khai báo var a:=4.

const a = 4 #khai báo hằng. Lưu ý phải gán giá trị cho hằng.

var ab = Vecto2(0,0) # Biến kiểu lớp

var arr = [1, 2, 3] #khai báo mảng

var d = {2: 3, 4: "Hello"} #khai báo từ điển

Conditional structure IF…THEN…ELSE

func _ready():

#     if(<điều kiện>):

#          [tập lệnh phía sau dấu tab phải thẳng hàng]

#     else:

#          [tập lệnh phía sau dấu tab phải thẳng hàng]

.     var a = false

.     var b = 0

.     if(a):

.          b = 1

.     else:

.          b = 2

Structure Match

func _ready():

.     var a = 0

.     Match(a):

.          1:

.               [tập lệnh phía sau dấu tab phải thẳng hàng]

.          2:

.               [tập lệnh phía sau dấu tab phải thẳng hàng]

For . loop

func _ready():

.     for i in 5:

.          [tập lệnh phía sau dấu tab phải thẳng hàng]

.     for i in range(5):

.          [tập lệnh phía sau dấu tab phải thẳng hàng]

#i chạy từ 0 đến 5-1

While loop

func _ready():

.     while(<điều kiện>):

.          [tập lệnh phía sau dấu tab phải thẳng hàng]

AUDIENCE IN GDSCRIPT

Creating and using classes are two essential tasks in object-oriented programming. Here is the recipe for creating and using the class on GDScript.

Create class

Construct properties (variables) and methods (object constructors)

class Math: #tên lớp

.      var total #thuộc tính

.      static func _sum(a: int, b: int) -> int: #phương thức

.          return a+b

Using class (create object corresponding to class)

#var <tên biến file script> = preload("đường dẫn script")

var MathGD = preload("Math.gd")

func _ready():

#     var <tên biến> = <tên biến script>.<tên lớp>.new()

.     var a = MathGD.Math.new()

.     print(a.sum(1,2))

Output: 3

In addition, we can also use the class by using inheritance with extends. Note: If you create a class that inherits the default class in Godot it is in script using class must be assigned to Node has the same type as the class you previously instantiated and used.

Today’s article I introduced and shared with you basic GDScript on Godot Engine. If you have any questions, please leave a comment or suggestion! For more information, you can refer to the basic videos at https://www.youtube.com/playlist?list=PLOk8LhtEwUVn8e3RUfk-rX_RB3f9_ulYg. Thank you for following this post! ?

The article achieved: 5/5 – (100 votes)

Tags: BasicEngineGDSCRIPTGodot
Previous Post

Download Welcome to the Game II Full – Game Deep Web creepy, horror

Next Post

Summary of Worldlist 2022 (Password list) used to Brute Force

AnonyViet

AnonyViet

Related Posts

Tips to fix the file is open in another program
Tips

Tips to fix the file is open in another program

May 21, 2025
7 ways to release RAM to accelerate your Windows computer
Tips

7 ways to release RAM to accelerate your Windows computer

May 21, 2025
The 10 best Torrent websites today – 100% still operate
Tips

The 10 best Torrent websites today – 100% still operate

May 20, 2025
Share Code Shop Selling Acc game extremely lightweight written in bootstrap
Tips

Share Code Shop Selling Acc game extremely lightweight written in bootstrap

May 19, 2025
Display the Internet speed on Windows Taskbar with Du Metter
Tips

Display the Internet speed on Windows Taskbar with Du Metter

May 18, 2025
Interesting facts about Google that you don’t know
Tips

Interesting facts about Google that you don’t know

May 17, 2025
Next Post
Summary of Worldlist 2022 (Password list) used to Brute Force

Summary of Worldlist 2022 (Password list) used to Brute Force

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Tips to fix the file is open in another program

Tips to fix the file is open in another program

May 21, 2025
7 ways to release RAM to accelerate your Windows computer

7 ways to release RAM to accelerate your Windows computer

May 21, 2025
Discover Supermix – Smart playlist on YouTube Music

Discover Supermix – Smart playlist on YouTube Music

May 20, 2025
The 10 best Torrent websites today – 100% still operate

The 10 best Torrent websites today – 100% still operate

May 20, 2025
Tips to fix the file is open in another program

Tips to fix the file is open in another program

May 21, 2025
7 ways to release RAM to accelerate your Windows computer

7 ways to release RAM to accelerate your Windows computer

May 21, 2025
Discover Supermix – Smart playlist on YouTube Music

Discover Supermix – Smart playlist on YouTube Music

May 20, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Tips to fix the file is open in another program

Tips to fix the file is open in another program

May 21, 2025
7 ways to release RAM to accelerate your Windows computer

7 ways to release RAM to accelerate your Windows computer

May 21, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET bongdaso