ICM Week5 Ball vs Brick

Youmingzhang
1 min readOct 9, 2020

a bouncing ball

This week I am creating a classic bouncing ball game. I remember that when I was young, I could really play this game all day. A ball is controlled by a rectangle where this rectangle can bounce the ball back to hit the bricks above.

Ball Object

Ball object contains the position of the bouncing ball x and y and a rectangle to bounce the ball back. Ball also has a bounce function that changes the bouncing direction of the ball and it has move() show() and score() function.

Game Feature

The rectangle object will be controlled by the mouse which player can move it from left to right.

Each time the ball collides with randomly generated bricks new bricks will be generated

When the ball’s y position exceeds the bottom game will end and it will show the player’s current score.

Hardship

Detecting collusion between objects is tricky. I still have some bugs on detecting the collision of the ball and bricks. I want to be precise and fast. I was wondering if there is a way to calculate the collision of different shaped objects.

--

--