Week5 Flappy Bird
This week I am creating a classical game flappy bird. The concept of this game is easy. I have one bird controlled by a mouse and pipe moving towards the bird. So I just need 2 objects — Bird and Pipe .
This class is the position of my bird and the control of the bird. It has show() and update() to display its position and a bird will fly if the mouse click as well as a calculate score function to check how many pipes passed. This class will also have some control variables such as gravity to move the bird downward and velocity to move the bird upward.
This class is moving pipes. It will contain the pipe position and width and height. I also wrote a collision detection function to check if a bird collides with any of the pipes. Pipes also have the velocity to move towards birds and a function to call collusion.
This game is not that hard to develop. The logic is sometimes tricky. For example, I am creating an array of pipes however I do not want pipes to fill the array to slow down my program running time. Each time a pipe passed the bird and moving out of the screen. I need to delete the pipe. Another part is tuning the speed and gravity and collusion. I have to run a couple of times to figure out the right number for these control variables. I had fun developing this game. I remembered that I played this game for a long time when it first came out. Now I am the one coding it lol.