Check my BlockBreaker


Hi guys,

here, I include a link to my version of the BlockBreaker. Although I’d like to add more stuff have in mind, I decided to keep it like it is now, because I want to move on to the next exercise.

I did some modifications:

  • I changed the sprites to get some more nice textures
  • change the effect of the smoke (kind of sparks fx now),
  • I added different sound effects depending on the surface where the ball is bouncing on (walls, paddle, brick, unbreakable brick)
  • showing the level number and the score, being updated in runtime.
  • added the ability of keeping down the left or the right button of the mouse, to force the ball on going to the right or left
  • I scaled up a bit the bricks, some times it was a bit frustrating, and the game experience wasn’t really nice. :stuck_out_tongue:

I think that’s all. Maybe I’ll add more stuff at some point, because with a so simple game, it’s really funny to add new features. :smile:

check it out:



Hey @JoseCuenca, thanks for the share. I like what you’ve done with this, very creative. I really like the hold right/left mouse button functionality! A possibility you’d share your technique on this?

I’ve only managed a score of 360 though, so it goes to show my gaming skillz are n00bish… :frowning:


Hi Deloric,

Thanks. Of course, I’ll share now what I’ve done with the mouse. It’s quite simple actually. :wink:

There was one thing I didn’t like: the inability of forcing the ball going to the right or left when bouncing.

So, what I did was to modify the OnCollisionEnter2D in the Ball.cs script.

void OnCollisionEnter2D(Collision2D collision)
	// defines a random value, in case the player doesnt use the mouse buttons
	float randomValue = Random.Range (-1.3f, 1.3f);
	// defines the tweak vector
	Vector2 tweak = new Vector2 (Random.Range(0f, randomValue), Random.Range(0f, 0.5f));
	if (isGameStarted) 
		if ( == "Paddle") 
			// if left mouse button is held 
			if (Input.GetMouseButton (0)) 
				tweak = new Vector2 (Random.Range(0f, -6f), Random.Range(0f, 0.5f));
			// if righ mouse button is held 
			else if (Input.GetMouseButton (1)) 
				tweak = new Vector2 (Random.Range(0f, 6f), Random.Range(0f, 0.5f));
			AudioSource audio = this.GetComponent<AudioSource> ();
			audio.Play ();
			Rigidbody2D rb = this.GetComponent<Rigidbody2D> ();
			rb.velocity += tweak;

So, basically the code is checking if you’re holding the left or right mouse button at the moment of the ball colliding with the paddle. It’s important to use GetMouseButton instead GetMouseButtonDown.

There is a strange effect sometimes though. With the mouse buttons I’m changing the velocity, so sometimes you might be able to compensate the speed that has the ball with an opposite velocity, and then the ball might even almost stop on top of the paddle or just get quite slow. It happened once to me. I should implement a kind of clamp method for the speed, so I’ll get sure always that the ball has a minimum speed. Still funny! :joy:

I hope is clear looking at the code, but please, let me know if have more doubts or other questions. :grin:



Thanks for sharing and for the offer. I’ll def keep it in mind. :slight_smile: