官术网_书友最值得收藏!

About GDScript

GDScript's syntax is very closely modeled on the Python language. If you are familiar with Python already, you will find GDScript very familiar. If you are comfortable with another dynamic language, such as JavaScript, you should find it relatively easy to learn. Python is very often recommended as a good beginner language, and GDScript shares that user-friendliness.

This book assumes you have at least some programming experience already. If you've never coded before, you may find it a little more difficult. Learning a game engine is a large task on its own; learning to code at the same time means you've taken on a major challenge. If you find yourself struggling with the code in this book, you may find that working through an introductory Python lesson will help you grasp the basics.

Like Python, GDScript is a dynamically typed language, meaning you do not need to declare a variable's type when creating it, and it uses whitespace (indentation) to denote code blocks. Overall, the result of using GDScript for your game's logic is that you write less code, which means faster development and fewer mistakes to fix.

To give you an idea of what GDScript looks like, here is a small script that causes a sprite to move from left to right across the screen at a given speed:

extends Sprite

var speed = 200

func _ready():
position = Vector2(100, 100)

func _process(delta):
position.x += speed * delta
if position.x > 500:
position.x = 0

Don't worry if this doesn't make sense to you yet. In the following chapters, you'll be writing lots of code, which will be accompanied by explanations of how it all works.

主站蜘蛛池模板: 肥东县| 牡丹江市| 河源市| 鹤峰县| 上思县| 博客| 庆安县| 建始县| 淅川县| 晋宁县| 宁武县| 大余县| 镇巴县| 阜平县| 黄冈市| 庆城县| 家居| 衡阳市| 佛教| 平果县| 无棣县| 蒙城县| 沙坪坝区| 德令哈市| 信阳市| 台江县| 永顺县| 西昌市| 平乐县| 湖口县| 井冈山市| 丹东市| 莆田市| 阿鲁科尔沁旗| 祥云县| 枞阳县| 武安市| 枣强县| 普兰县| 海兴县| 高雄市|