[GAME] My Block Breaker Game!

Hello,

You can play my game here:
https://gamebucket.io/game/c62166f2-ec79-4878-a2dc-962e24e2e078

Added lives system, 5 levels, a semi-circular paddle for better control. Custom audio track from my music band Chantage, let me know if you like the song

The only bug is that the ball still sometimes enters a â€śboring loopâ€ť, especially near the wall colliders. Perhaps I need to somehow check if the ball is in a certain range of linear movement, and add some velocity in x or y direction accordingly. I will be glad if anyone who has already solved the problem, can leave a short comment.

Best Regards,
Tolga

Hello,

I upgraded to v5 and built for WebGL, and fixed the â€śboring loopâ€ť problem. You can play the latest version here:
http://chantage.info/blockbreaker/index.html

The approach I used for the boring loop bug, is to check the velocity in each direction, and if itâ€™s below 1, add 1 in that direction. The random.range approach doesnâ€™t solve the problem. And if you add velocity in each bounce the ball speeds up too fast. You can find the actual code from the ball.cs below, itâ€™s not very elegant but it works.

``````	void OnCollisionEnter2D (Collision2D collision) {
if (hasStarted){
GetComponent<AudioSource>().Play();
if(this.GetComponent<Rigidbody2D>().velocity.x < 1 & this.GetComponent<Rigidbody2D>().velocity.x > 0){
this.GetComponent<Rigidbody2D>().velocity += new Vector2(1f,0f);
}
if(this.GetComponent<Rigidbody2D>().velocity.x < 0 & this.GetComponent<Rigidbody2D>().velocity.x > -1){
this.GetComponent<Rigidbody2D>().velocity += new Vector2(-1f,0f);
}
if(this.GetComponent<Rigidbody2D>().velocity.y < 1 & this.GetComponent<Rigidbody2D>().velocity.y > 0){
this.GetComponent<Rigidbody2D>().velocity += new Vector2(0f,1f);
}
if(this.GetComponent<Rigidbody2D>().velocity.y < 0 & this.GetComponent<Rigidbody2D>().velocity.y > -1){
this.GetComponent<Rigidbody2D>().velocity += new Vector2(0f,-1f);
}
}
}``````

Oh, thatâ€™s a nice, simple idea. Perhaps Iâ€™ll try that for my version, too. Strange gravity behavior and boring loops are death reason No.1 for many of my players. Combined with the scoring system I implemented, some have been quite frustrated, .