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

Share book
  1. 298 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Godot Engine Game Development Projects

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

Chris Bradfield

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Godot Engine Game Development Projects an online PDF/ePUB?
Yes, you can access Godot Engine Game Development Projects by Chris Bradfield in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Programación de juegos. We have over one million books available in our catalogue for you to explore.

Information

Year
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...

Table of contents