Sonstiges: Developer Diary - The Creation of a 3DS/Switch Game
Michael GrŲnert, am 26.12.2016, Seite 6 von 14
Part 6: GONG! The first mini game
Our character is ready to start a first mini game. Time to create one! The objective is to create a simple game so that we have a working one to implement and test other things with. This includes, for example, the connection and switching between the world and the games. The game itself is not so important for now. When I think about which game is easiest to implement, Pong always comes to my mind. Two rectangles that can move vertically and a ball played back and forth between them. It would be nice, of course, if the game had something more to offer, but this is something the player may add with the aforementioned game development mechanics thatíll become one of the core features of my project. So itís decided: We are programming a Pong clone! Although there is no legal problem to create such a thing, we want to at least come up with an own name for it. How about a more powerful beat instead of a "ping" and a "pong"? Let's call it "GONG!" for now.
The game itself is relatively easy to implement: We draw vertically enlarged cuboids on the left and right side on the screen with another cuboid in the middle which represents a nice angular ball. When we start a round, the ball is accelerated in the direction of a player. Which player receives the ball is randomized. The player can use their own movement to determine the rebound angle of the ball and thus try to send the opponent as difficult shots as possible. If the ball passes behind a player, this gives one point for the other. Once a certain score is reached, the player wins. The opponent could be a second human player. Iím thinking of the advantage of the Joy-Cons of the Nintendo Switch here - these can be split among two players. It would be possible to play together with one 3DS, too, even if it is much less comfortable. My project would not be the first to offer this option. But since we also want to play and test alone, we create an AI (Artificial Intelligence) which we can compete against.
You donít need much to breathe life into the opponent. We create a method that is executed in each frame and moves the CPU (computer-controlled) paddle towards the direction of the ball. In doing so, we take care to make this movement is not too unrealistic, meaning the paddle does not move faster than it would if it were controlled by a person. The CPU should follow the same rules as a human player. Since the ball can move faster on the Y axis (vertically) than a paddle, this AI quickly reaches its limits and can easily be tricked out. It should therefore learn to think ahead. To achieve this, the AI can calculate where the ball will arrive on the Y axis at its current speed. However, this would make the AI play perfectly and therefore never lose. We have to find a solution in which one can win but not with ease. I have solved this by letting the AI predict only a few frames instead of the impact point of the ball. Depending on how far the CPU can look into the future, itíll play better. This foresight may also be used to introduce different selectable difficulty levels.
The first mini game: GONG!
Let The Games Begin!
Our GONG! is ready for first gaming fun! Of course, there is still a lot of logic running in the background. When a player scores the next round is started. This resets the ball and the player to their starting positions. The player against whom the point has been made will open the next round. There should be enough time between the events to allow a human player to realize whatís happening. A button allows to pause the game. During this, the movements of the ball and the players are interrupted. The motion vectors (direction and speed) are saved and reassigned to the objects after the pause is ended. So far we donít have an end after reaching a certain number of points or something like that.
GONG! still has a lot of potential for features. How about four players instead of just two? Instead of the walls at the upper and lower border of the screen there could be another two players. Or how about a double? On each side, two players either split the playing field into two halves or use the complete vertical with a slightly offset to each other. For this, we should also raise the difficulty by using two balls at the same time or increasing the speed of this one ball. The number of players and difficulty levels should be part of the developable abilities. The same goes for the graphics. The simple cubes could be replaced by pretty detailed and colored shapes.
For now I would like to go back to the "Overworld" and to start another very important basis of the project - the inventory. I want to add something to this inventory that we can use to start GONG! instead of walking to the start cube. However, the inventory will be the subject of my next diary entry.
Do you prefer to read this diary in the developer's mother tongue? Then click to read this diary entry in the original German language!