Chapter 4. Advanced Game Content Generation with a Fruit Chopper Game

As I've mentioned before, physics has always been a huge and massively important topic in the process of developing a game, and we will keep using it with the majority of the games in this book, as there is no modern game that does not run on a physics system.

This is a book about iOS, yes? So, why not discuss the touch inputs, and how to recognize a swipe effect a bit more? Unreal Engine does not support the swipe action (at this moment, Version 4.3) by default, but there are many ways we can recognize it.

What makes players compete nowadays? Score! Let's scratch the surface and see how we can add scores to our games and wire the game to show it using UI text.

By the end of this chapter, you will be able to:

  • Detect a swipe over a fruit
  • Spawn actors during runtime
  • Randomly generate objects
  • Use different spawn points to give random gameplay
  • Load a win or lose screen
  • Add a UI text element
  • Calculate the score
  • Communicate different blueprints
  • Build a particle system
  • Get your hands on the Cascade editor
  • Spawn particle emitters when needed
  • Build a custom for loop using macros

The project structure

If you are going to browse the included project files, then you will find that they were made with Unreal Editor 4.30; if you are using a higher version, it might let you know that the project will be upgraded to a higher version, which is an irreversible step unless you are running your project within a version control system such as Git. Just keep that in mind!

For this game sample, I made a blank project template without the starter content. I got some photos of real fruit and sliced each picture into two pieces. For example, a banana will have three sprites, the full fruit and another two sprites of it splatted. The game is a 2D game, but following the same approach with 3D assets will let you get the same result. As for the folder structure, you will find the following contents:

  • The blueprints folder: This contains all of the blueprints (regardless of types)
  • The levels folder: This holds three levels, which are the game itself and another two small levels for the win and lose states
  • The materials folder: This contains only one material that will be used for the particle system
  • The particles folder: This contains one sample of the particle system that will be used as an effect for the chopping
  • The sprites folder: This is the home for all of the textures and sprites you will need.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.225