Brick Game with Source Code

Brick games are fun to play. But, generally speaking these games are more exciting when we develop them as C++ developers. As a beginner you may also be trying to develop games but finding no clear references on the internet, right?

For that sake we decided to take your burden of intense research on our shoulders and provide you people with some premium information about brick games for free

So, are you ready to dive deep into the history, development and a list of some already developed brick games with their source codes? Let’s get started.

History of Brick Game

Alexey Pazhitnov invented the brick game in 1984-1985. A Russian programmer developed the game, but it was initially introduced to China. 

It is a traditionally created electronic handheld game. Within the few years of its launch, it became famous among children and adults as it proved to be a good time pass activity that requires some brainstorming. 

The game was displayed on a 10 x 20 grid screen. It was a modified version of the Tetris game. Both have the same screen sizes. But now, the game is available in various sizes and shapes. It consumes two AA batteries to work. 

The brick games are usually arranged in an alphabetical sequence; it is easier for the user to choose the game he wants to play. 

The speed and the difficulty level of the game are adjustable as per our will. The brick game was an easily accessible cheap toy, and anyone could easily afford to buy it for their kids or themselves. It was a readily available gaming product in the market.

Brick Game with Source Code

Gaming Engines of Brick Game

A dedicated software used for creating games by utilizing the features like rendering graphics, collision detection, artificial to animated intelligence, etc., is known as a gaming engine

Without using a gaming engine, one cannot develop any video game, whether it’s a 2D or 3D game. In short, a gaming engine is the gist behind game development. Some of the best gaming engines which support the development of the Brick Game are as follows:

Brick Game Variants

Mainly, there are two variants of brick games developed by Russia and China.

  • Chinese Variant:

The most common variant of the brick game that is world-widely available was the Chinese Brick Game. The game uses two AA batteries to play, and it is available in many different shapes and sizes. 

The ranges vary from the minute keychain model to unique and large models that look like a game controller or a mobile phone. The Super Mouse and Happy Rabbit brands work for the vast distribution of Chinese Brick Game worldwide.

  • Russian Variant:

This variant is only available in European countries, Russia, and former Soviet Republics.

The game only comes in a single model of a standard, regular, and rectangular shape with a curved part in the middle, which segregates the LCD and the buttons of the game. 

The Russian Brick Game can be played using AAA and AA batteries. And the best feature of this game is its loud audio. 

Variant of Menus

The brick game was developed by the simple cloning of the Tetris game, so the early variant consists only of B variants. Later on, the different units required an excellent menu to implement popular games.

  1. Version 1

The simplest of all was that all versions are version one as the game is displayed by representing numbers on the screen.

  1. Version 2

There is a G on the top of the game in the second version. Any letter represents the sort of game displayed and the modifiers. The advanced versions had a spinning G on their top.

  1. Version 3

The third version of the brick game is available with an attachment of the preview of the game in it that is linked with the modifier numbers, letters, and numbers. The spinning letter feature was developed in the ROMs with the letter version.

Modes of Brick Game

There are many modes of the brick game. Some of them are the following:

  1. Tetromino Game:
image 14 - Brick Game with Source Code

The Tetromino game was developed by cloning the Tetris game. This game is available in many variations that range from ordinary Tetris pieces to complex variations that feature unusual pieces and pieces that cannot shoot.

The game is named the Brick Game on the console packaging or user’s manual. The game is given a different name to avoid the copyright infringement of the original Tetris game.

Source code 1 // Source code 2 // Source code 3 // Source code 4 // Source code 5 // Source code 6

  1. Tank Game
image 13 - Brick Game with Source Code

The game is similar to Battle City, a multi-directional shooting game. The player controls a spaceship-type tank, which shoots the enemies displayed in the game until a specific number is reached.

Each level will feature a Boss Battle, and at the end, you have to beat a huge tank. The Boss level is part of some versions of this game.

Source code 1 // Source code 2 // Source code 3 // Source code 4 // Source code 5 // Source code 6

  1. Shooting a Single Block
image 10 - Brick Game with Source Code

The player has to target single shoot blocks from below or above if inverted in this game. It has to be done until a 10-block line is formed and cleared after formation.

The objectives and features of this game are similar to the Tetris game.

Source code 1 // Source code 2 // Source code 3 // Source code 4 // Source code 5 // Source code 6

  1. Car Racing Game
image 11 - Brick Game with Source Code

In this version, the player has to switch the car’s movement from left to right lane and vice versa to avoid hitting the vehicle passing in the lanes.

If the player hits his car with any other car, he will lose the game. The difficulty level of the game increases as the speed of the car gradually increases every time a level is cleared.

Racing games can be develope in C++ using graphics and game engines.

Source code 1 // Source code 2 // Source code 3 // Source code 4 // Source code 5 // Source code 6

  1. Vertical Shooter Game:
image 12 - Brick Game with Source Code

It is the most common type of the Brick game where the rows of blocks are randomly generated, which gradually moves down with the screen and must be destroyed by shooting before they reach the bottom of the screen.

There is another game variant where you have to hit the randomly occurring rows. This variant gives you the feature to shoot with two shooters at the cost of one life. The player loses his only life if the blocks reach the bottom of the screen.

Different Kinds of Brick Games:

Following are the kinds of brick games available to play:

  • ArithmeBricks

Jan Kaliszewski developed this game in 2014. This game was initially tested on Linux and then specifically on Android. After that, it was launched on other platforms to work upon.

The Main.py file is the main script of the program of this game. Slider is used to choose the game’s difficulty level, which is present at the bottom of the screen. 

Then we have to click on the new game or play more buttons to start the game. The user has to drag and drop the brick in digits and operator form to develop valid form equality like 12 + 3 = 17 -2.

All the arithmetic bricks must be used, and as a result, at least one valid solution will be generated.

image 8 - Brick Game with Source Code
  • Thock

In Thock, the user had to create or join the room. He will choose whether he wants to practice or play online. After joining the room, he will add his username and room ID for further proceedings. 

image 7 - Brick Game with Source Code

Then the user has to select whether he is ready or not ready. Then he had to press ‘r’ to get ready, and the match would begin after that. The match will be between the chicoon and the player. A sentence will be given to both of them to write. 

The speed of writing and progress for both of them will be measured. The user had to write his sentence in the input. One who writes the sentence will win the game.

  • Simple Brick Games
image 15 - Brick Game with Source Code

This game emulates the old handhelds that are of low cost. 14 different mini brick games have customized buttons, backgrounds, and textures. 

The high scores for each game are recorded, and levels’ speed and difficulty level can be changed. For the main menu navigation, the user has to press left to right to change the game. 

He can also increase the level and the speed from the menu, and then he can start the game by pressing the action button.

we hava another version of this game with 999 bricks games.

  • Brick Breaker

Brick breaker game is one of the famous games in which there is a wall of bricks that will proceed downwards, and then there is a ball present on the paddle at the bottom of the screen, which is moveable.

The user has to strike and break the bricks until the wall is destroyed to win the game.

image 6 - Brick Game with Source Code
  • Brick Craft

The user had to build mini crafts using the bricks in this game. He can move the bricks using WASD keys, and to jump, he can press on the spacebar. The tab key is used to switch between the inventory immediately and the I key for opening the inventory. 

image 9 - Brick Game with Source Code

The right-click is used to add a brick (block) to your game, and the mouse wheel is needed to rotate that block. 

  • Dino Brick

In this game, the user has to move the dino so as not to hit any wall. The dino in this game is represented by white brick that moves with the help of the W and S key to jump upwards or bend downwards to escape the red bricks, which is the ball.

Q key is used to quit the game, R key is used to restart the game, and P key is used to pause the game.

image 5 - Brick Game with Source Code
  • Tetris

Tetris is a simple video game in which the user has to adjust the block that is moving down the screen by rotating it or moving it to left and right by using the A and D keys.

The block is moving with a certain default speed. The speed can be increased if the user is sure about the block’s position.

image 4 - Brick Game with Source Code

 The main aim of the user is to fill all the empty spaces of the blocks by placing them accordingly. They will be rewarded some pointy for doing it.

  • Bricks VR

Bricks VR is a sandbox-building game developed in VR. It is a multi-player game. We will develop the creation in this game by putting together the blocks. We can also invite friends to a shared world and build mini creations together. 

The user can choose a brick of any color as there are 16 million types of bricks with different colors. You can give access to your world to outsiders to visit and get mesmerized. In contrast, you can also lock your world (account), so that outsiders cannot change it.

  • Bushed Bricks

Bushed bricks are one of the unique brick games in which the user had to join the tiles of the same color together.

If he combined 4 tiles of the same color or more and positioned them in an appropriate color line, the user will be rewarded with the points according to the number of bricks combined. 

image 3 - Brick Game with Source Code

To win the game, you need to combine 400 steps or earn 5000 points. The user can use up, down, right, and left keys from the desktop or swipe from the mobile screen to combine the tiles of similar colors.

Creating Brick Game Using Gaming Engine

The game we will develop has been tested on the Store App and Windows Phone. 

Features Needed to Create a Brick Game

Following are the features that are used to create a brick game.

  1. A camera with an orthographic projection setting is apt for the 2D game.
  2. A game manager game object holding the game manager script so our game could run efficiently
  3. A directional light
  4. A ball that moves around the boundaries and helps to clear the levels
  5. The floor will decrease the player’s life if the ball strikes with it.
  6. A paddle is used in the game, which prevents the ball from striking the boundary.
  7. The presence of SideBlocks will help the ball stay on the level.
  8. The status Text Game Object will be used to present the text messages.
  9. The Block which the ball will be hitting.
  10. Organization of four BlockRow objects.

Purpose of the game

The user has to regulate the ball, eventually controlling the whole game. The game’s primary purpose is to hit the blocks on a level by the ball. If we destroy all the blocks without losing our life, we will be declared a winner of the game as we had secured our life and finished the blocks.

But we will lose our life if the ball hits the wall. On hitting the walls, we will lose all our lives and then lose the game a specific number of times.

We had to start a new game, either winning or losing because we had no other option.

Exploring the GameObject’s Code

Each GameObject code is explored and searched individually. Let me inform you that the whole codebase program for this game had been scripted on the Visual Studio Community. We can check the Visual Studio Tools for the Unity gaming engine for debugging purposes. 

Playing with the Graphics in 2D

  • There are three quads of the game with a collider here: LeftBlock, RightBlock, and UpperBlock.
  • The physics is applied to the ball’s material, making it a bouncy material, with friction 0 and bounciness 1.
  • There will be an energy loss observed, so no velocity is lost. It happens because of each collision performed by the ball.
  • The ball will bounce back on hitting one of the three blocks.

What is a Paddle?

A quad equipped with a PaddleScript script element and a 2D BoxCollider is known as a paddle.

The paddle script controls the input from the user, and the user controls the input by the keyboard or the touch screen. He handles the position of the LeftBlock and the RightBlock. The position of both the blocks is clinched between the position of two border blocks. 

We can also opt for another option to develop a kinematic RigidBody2D with the assistance of a paddle. We also have to AddForce to increase the ball’s velocity along the x-axis. But this all depends upon the user’s input.

What is a Block?

We can refer to the block as a quad prefab developed with the help of BlockScript and a BoxCollider2D component. It is marked with “Block”.

There is an initialized color technique in BlockScript. It is used to color the blocks according to our will.

The 2D CollisionMethod increases the player’s score by subtracting one block from the alive blocks, setting that block inactive. Whenever a block is set inactive, the player is awarded a point. 

The destroy method is not applicable as it activates all blocks when the game restarts either the player loses or wins.

How the Ball Works?

We can refer to the block as a quad prefab developed with the help of BlockScript and a BoxCollider2D component. It is marked with “Block.”

There is an initialized color technique in BlockScript. It is used to color the blocks according to our will.

The 2D CollisionMethod increases the player’s score by subtracting one block from the alive blocks, setting that block inactive. Whenever a block is set inactive, the player is awarded a point. 

The destroy method is not applicable as it activates all blocks when the game restarts either the player loses or wins.

Visiting The Game Manager Script

At last, we will be visiting the GameManager script. At its bottom, we can see an enumeration known as GameState. The 5 states of the game are included in it. 

The following are these states:

  1. Start
  2. Playing 
  3. Won
  4. Lost a life 
  5. Lost all lives

While constructing these games, state manager is a common practice. It all happens to achieve the user’s interaction and different actions.

The references of the blocks can be stored so we can achieve some static fields, scores, some lives, and activated blocks.

Methods in Brick Game

Following functions or methods are used in the source code of the brick game.

Decrease Lives Method

This function is called by using the FloorScript function. It decreases and then stops the ball (velocity=0). Consequently, it further checks the availability of the lives to set the game. An appropriate text is regarding Status Text Object Game, depending on the game.

Update Method

The game’s state is taken into account by using the update method. The user’s input requirement is checked using the keyboard or touch input at the states: start, won, lost life, and lost all lives. User input is given to the paddle in this state as nothing happens to it in the playing state. It is all controlled by PaddleScript.

Start Method

The Block Game Object references are required for the game when we opt for the StartMethod. A reference to BallScript is also taken. On the other hand, the InputTakenMethod returns the value as true or false. The value would be true if the player touched the screen. Moreover, a StatusTextObject is also seen.

Restart Method

Lastly, the Restart Method will be needed for the final touch-up.

  • The color of the block can be changed.
  • Using the loop, we can activate all our blocks.
  • The score counter and lives of the game are restored.

Conclusion

With the detailed information provided above, we hope that you are now up with how to develop your very next brick game. For instance we also have added source codons to assist you in writing your own source code. Start developing your brick games in C++ and let us know if you have any queries or doubts during the process.