What happens in the written code? First, we import the library. Then we create an object of type Game, setting the resolution of our application, in this case 480 pixels wide and 640 pixels high. Phaser.AUTO means that the render type will be selected automatically. Optionally, you can specify Canvas or WebGL. The fourth parameter sets the parent DOM object for the game, we do not specify it.
In the create () function, we add a static sprite with the background of our game. The sprite fills the space specified in the first four parameters to tileSprite.
Now let’s move on to the most interesting thing – let’s fill our game with logic. After declaring the variable game and before the preload () function, we will declare objects with the player’s and computer’s rackets, a ball, and also indicate the speed of their movement: