Making a 2D Game

In this chapter, we are going to build a simple 2D game that can run on the desktops of all major platforms by utilizing the Electron framework. We aren't going to build the game engine, though. To save time and to focus on the result, I am going to use Phaser. Phaser is a fast, free, and fun open source framework for Canvas and WebGL that powers browser and mobile games. You can check out Phaser at https://www.phaser.io/.

First, I am going to guide you through the process of creating a new game project scaffold. We will be packaging simple Phaser examples as a desktop application in order to render images and manipulate game sprites.

sprite is a computer graphics term for a two-dimensional bitmap that is integrated into a larger scene, most often in a 2D video game. Essentially, a sprite is a game object that we can move, flip, manipulate, and so on.

We will also learn about handling keyboard events. By the end of this chapter, you will know how to get started with game development for multiple platforms.

In this chapter, we will cover the following topics:

  • Configuring a game project
  • Running a Hello World example
  • Rendering background images
  • Preventing window resizing
  • Rendering a sprite
  • Scaling sprites
  • Handling keyboard input
  • Flipping sprites based on their direction
  • Controlling sprite coordinates
  • Controlling sprite speed
..................Content has been hidden....................

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