This is the code repository for Learning GDScript by Developing a Game with Godot 4, published by Packt.
A fun introduction to programming in GDScript 2.0 and game development using the Godot engine
In the digital landscape driven by interactive experiences, the demand for creative individuals with the skills to create captivating games has never been higher. Written by Sander Vanhove, a seasoned game developer with over 20 games to his credit, this book will serve as your entry point into game development, showing you how to leverage the powerful features of the open-source, versatile GDScript 2.0 to develop your ideas, from simple platformers to complex RPGs.
This book covers the following exciting features:
- Develop your GDScript 2.0 programming skills from basic to advanced, emphasizing code cleanliness
- Harness Godot 4's integrated physics engine to control and manipulate in-game objects
- Design a vibrant and immersive game world by seamlessly integrating a diverse array of assets
- Master the art of processing input from various sources for enhanced interactivity
- Extend the reach of your game by learning how to export it to multiple platforms
- Implement basic AI systems and incorporate simple multiplayer functionality for a dynamic gaming experience
If you feel this book is for you, get your copy today!
All of the code is organized into folders. For example, Chapter03.
The code will look like the following:
func _ready():
var inventory = [
"Boots",
"Bananas",
"Bees"
]
print(inventory[100])
Following is what you need for this book:
This book is for programmers, game designers, game developers, and game artists who want to start creating games in Godot 4. If you’re new to coding or game development, looking for a new creative outlet, and want to give Godot 4 and GDScript 2.0 a try, this book is for you. While no prior knowledge of programming or Godot is required, this book gradually introduces more complex concepts as you advance through the chapters.
With the following software and hardware list you can run all code files present in the book (Chapter 1-16).
Chapter | Software required | OS required |
---|---|---|
1-16 | Godot 4.2.1 | Windows, macOS, or Linux |
1-16 | GDScript 2.0 | Windows, macOS, or Linux |
- Page 33, "We have assigned new valuesv to variables using the assignment operator (=)" it should be "We have assigned new values to variables using the assignment operator (=)"
- Page 33, Figure 2.6: Line 11 reads
number_of_lives -= number_of_lives
should readnumber_of_lives -= fire_ball_damage
- Page 36, This snippet of code should print out the following:
The number of lives is 3.
should beThe number of lives is 1
- Page 52, Last code snippet should be
print("You live" if number_of_lives > 0 else "You died!")
instead ofPrint("You live" if number_of_lives > 0
- Page 62, "Here, we remove the first element of the inventory array as long, so the array has a length of more than three elements." it should be "Here, we remove the first element of the inventory array as long as the length is more than three elements."
- Page 64, Line 2 of the code snippet:
For item in inventory.size():
should readFor item in inventory:
- Page 136, Under section Different types of exported variables "including the outer values of 0 and 20." should be "including the outer values of 0 and 10."
- Page 194, "Save the script as collectible.gb" should be "Save the script as collectible.gd"
Sander Vanhove has been creating games with the Godot Game Engine for over five years, releasing over 20 games on multiple platforms. However, his interest in games started long before that, taking him from engine to engine before finally settling. This enthusiasm, along with his master's in computer science, gave him a broad knowledge of programming and AI, which he now applies in his day job as a lead game developer and technical artist of a studio that uses the Godot Engine. You can always find him working on that next project, learning new game development techniques, or trying to teach people how to use Godot.