Godot Engine Game Development Projects
eBook - ePub

Godot Engine Game Development Projects

Build five cross-platform 2D and 3D games with Godot 3.0

Chris Bradfield

Buch teilen
  1. 298 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Godot Engine Game Development Projects

Build five cross-platform 2D and 3D games with Godot 3.0

Chris Bradfield

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Create interactive cross-platform games with the Godot Engine 3.0About This Book• Learn the art of developing cross-platform games• Leverage Godot's node and scene system to design robust, reusable game objects• Integrate Blender easily and efficiently with Godot to create powerful 3D gamesWho This Book Is ForGodot Engine Game Development Projects is for both new users and experienced developers, who want to learn to make games using a modern game engine. Some prior programming experience is recommended.What You Will Learn• Get started with the Godot game engine and editor• Organize a game project• Import graphical and audio assets• Use Godot's node and scene system to design robust, reusable game objects• Write code in GDScript to capture input and build complex behaviors• Implement user interfaces to display information• Create visual effects to spice up your game• Learn techniques that you can apply to your own game projectsIn DetailGodot Engine Game Development Projects is an introduction to the Godot game engine and its new 3.0 version. Godot 3.0 brings a large number of new features and capabilities that make it a strong alternative to expensive commercial game engines. For beginners, Godot offers a friendly way to learn game development techniques, while for experienced developers it is a powerful, customizable tool that can bring your visions to life.This book consists of five projects that will help developers achieve a sound understanding of the engine when it comes to building games.Game development is complex and involves a wide spectrum of knowledge and skills. This book can help you build on your foundation level skills by showing you how to create a number of small-scale game projects. Along the way, you will learn how Godot works and discover important game development techniques that you can apply to your projects.Using a straightforward, step-by-step approach and practical examples, the book will take you from the absolute basics through to sophisticated game physics, animations, and other techniques. Upon completing the final project, you will have a strong foundation for future success with Godot 3.0.Style and approachThe book is divided into five parts; each covering a different small-game project using a straightforward, step-by-step approach and practical examples. The book will take readers from the absolute basics through sophisticated game physics, animation, and other techniques.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Godot Engine Game Development Projects als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Godot Engine Game Development Projects von Chris Bradfield im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming Games. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781788836425

Jungle Jump (Platformer)

In this chapter, you'll build a classic platform, style game in the tradition of Super Mario Bros. Platform games are a very popular genre, and understanding how they work can help you make a variety of different game styles. The physics of platformers can be deceptively complex, and you'll see how Godot's KinematicBody2D physics node has features to help you implement the character controller features you need for a satisfying experience. Take a look at the following screenshot:
In this project, you will learn about:
  • Using the KinematicBody2D physics node
  • Combining animations and user input to produce complex character behavior
  • Creating an infinitely scrolling background using ParallaxLayers
  • Organizing your project and planning for expansion

Project setup

Create a new project. Before you download the assets from the link that follows, you need to prepare the import settings for the game art. The art assets for this project use a pixel art style, which means they look best when not filtered, which is Godot's default setting for textures. Filtering is a method by which the pixels of an image are smoothed. It can improve the look of some art, but not pixel-based images:
It's inconvenient to have to disable this for every image, so Godot allows you to customize the default import settings. Click on the icon.png file in the FileSystem dock, then click the Import tab next to the Scene tab on the right. This window allows you to change the import settings for the file you've selected. Uncheck the Filter property, then click Preset and choose Set as Default for 'Texture'. This way, all images will be imported with filtering disabled. Refer to the following screenshot:
If you've already imported images, their import settings won't be updated automatically. After changing the default, you'll have to reimport any existing images. You can select multiple files in the FileSystem dock and click the Reimport button to apply the settings to many files at once.
Now, you can download the game assets from the following link and unzip them in your project folder. Godot will import all the images with the new default settings, https://github.com/PacktPublishing/Godot-Game-Engine-Projects/releases
Next, open Project | Project Settings and under Rendering/Quality, set Use Pixel Snap to On. This will ensure that all images will be aligned properly—something that will be very important when you're designing your game's levels.
While you have the settings window open, go to the Display/Window section and change Stretch/Mode to 2d and Aspect to expand. These settings will allow the user to resize the game window while preserving the image's quality. Once the project has been completed, you'll be able to see the effects of this setting.
Next, set up the collision layer names so that it will be more convenient to set up collisions between different types of objects. Go to Layer Names/2d Physics and name the first four layers like this:
Finally, add the following actions for the player controls in the Input Map tab under Project | Project Settings:
Action Name Key(s)
right D, →
left A, ←
jump Space
crouch S, ↓
climb W, ↑

Introducing kinematic bodies

A platform game requires gravity, collisions, jumping, and other physics behavior, so you might think that RigidBody2D would be the perfect choice to implement the character's movement. In practice, however, you'll find that the realistic physics of the rigid body are not desirable for a platform character. To the player, realism is less important than responsive control and an action feel. As the developer, you therefore want to have precise control over the character's movements and collision response. For this reason, a kinematic body is usually the better choice for a platform character.
The KinematicBody2D node is designed for implementing bodies that are to be controlled directly by the user or via code. These nodes detect collisions with other bodies when moving, but are not affected by global physics properties like gravity or friction. This doesn't mean that a kinematic body can't be affected by gravity and other forces, just that you must calculate those forces and their effects in code; the engine will not move a kinematic body automatically.
When moving KinematicBody2D, as with RigidBody2D, you should not set its position directly. Instead, you use either the move_and_collide() or move_and_slide() methods. These methods move the body along a given vector and instantly stop if a collision is detected with another body. After KinematicBody2D has collided, any collision response must be coded manually.

Collision response

After a collision, you may want the body to bounce, to slide along a wall, or to alter the properties of the object it hit. The way you handle collision response depends on which method you used to move the body.

move_and_collide

When using move_and_collide(), the function returns a KinematicCollision2D object upon collision. This object contains information about the collision and the colliding body. You can use this information to determine the response. Note that the function returns null when the movement was completed successfully with no collision.
For example, if you want the body to bounce off of the colliding object, you could use the following script:
extends KinematicBody2D var velocity = Vector2(250, 250) func _physics_process(delta): var collide = move_and_collide(velocity * delta) if collide: velocity = velocity.bounce(collide.normal)

move_and_slide

Sliding is a very common option for collision response. Imagine a player moving along walls in a top-down game or running up and down slopes in a platformer. While it's possible to code this response yourself after using move_and_collide(), move_and_slide() provides a convenient way to implement sliding movement. When using this method, the body will automatically slide along the colliding surface. In addition, sliding collisions allow you to use metho...

Inhaltsverzeichnis