Introduction
Indivisual project. A classical breakout game programmed by OpenGL, you can press W/S to choose your level, and then press enter to start a game.
You can press Space to shoot out your ball, and press A/D tto control your paddle. Destroying bricks would spawn some items randomly, they can both help or hamper you from completed the levels.
Learnt a lot from https://learnopengl.com/
Reference
Download
Features
Rendering
Render the scene with one shader program programmed by GLSL. For each different game object in the scene, bind a particular VAO and VBO then draw it. For each brick in the scene, if it was not labeled as solid, once it gets in contact with the ball. it would be labeled as destroyed and would not be rendered since the next frame.
Level Loading
Levels' data are saved in texts files in the format of the array. Each solid brick would be represented by 0, and 1-3 refers to different colors of bricks. All levels would be load at the beginning of the game, and once the player destroys all the bricks in the level, the next level would be loaded. Also, if the ball's position is below the lower edge of the screen, then the player would be failed, the level would be reset.
Collision Detection
In each frame, compute the closest point in each brick's edge to the ball, if the distance of any of them is less than the ball's radius, then the collision would be reported, and the brick that engaged in this collision would be labeled as destroyed, then the x/y axis velocity of the ball (depends on the collision's direction) would be reversed.
Post processing
All the game scenes would be rendered into a Frame Buffer Object (FBO) at first. If the player hit a solid brick or gets some debuff props, the post-processing shader would add some visual effects to the scene in the FBO correspondingly, and then draw the processed scene in the FBO to the screen.
Props
When the bricks are destroyed, there would be some props that spawned randomly. Collision detection would also be applied between the paddle and those items, and once the collision was detected, the corresponding effect would become effective.
Confuse/ Chaos
Realized by adding effects in post processing shader.
Sticky
Your paddle would be sticky in few seconds. Realized by update sticky state in rendering loop.
Extension/ Speed up
Extend your paddle. Realized by update the paddle/ ball parameters directly.
Pass through
Make your ball can pass through bricks in few seconds. Realized by adding a jugement before the ball's boncing.
Particle System
Used a unique shader to draw particles, and update each particle's lifetime, and position in every frame. In a particle's lifetime, it can also move with its initial velocity. Once its lifetime is ended, reset its position and lifetime in replace and spawn a new particle. New positions are random variables in a certain range that are decided by the ball's position.
Game State
There are three types of game states in the game: Metum Active Win. In each state, the unique text would be rendered to instruct the player. Also, each state would process different input to ensure those states can be switched successfully.
Comments