THE WORST Arkanoid

Here is it:


  • it has nothing
  • except for a tweak that forces collision happen in a way you never get into a boring loop (controls bouncing angles)
  • you can also control the ball bounce depending on how far from the center it hits your ship
  • has no gravity either
  • in 9th level there is a UFO enemy that fires guided missiles on your ship
  • its pretty fast paced and difficult since I didn’t add any extra balls or any other things

I wanted to but for now I feel like I want to proceed more deep into the course than upgrading this. I’ve been following the arkanoid part of the course for ages so now all I want is something different. But its probable I will return back to this project in the future.

I’d like to add:

  • smarter level progression
  • different bonuses
  • game score
  • more lives
  • ball speeding up with time
  • animated backgrounds
  • more appealing blocks
  • different enemies
  • many many many more other levels
  • android build

C&C an R&R are most appreciated!!!


I like the clean look and the ball movement, just like i remember from the old arkanoid games!
can you please paste the code for this, i wondered about this myself, but still a rookie to all of this :smile:

Hey dude,
well its simple (because I was able to do it myself :smiley: )

There are 3 things…

  1. on ship I have collision detection (the same like you got on bricks etc… void oncollision something), inside it there is a script that reads x of the ball and x of the ship. Difference of these values (the greater the further from the ship ball hits) is then multiplied with x vector of the speed of the ball. (thuss the ball bounces more sideways if its far from the ship center).

  2. i also detect y speed in this collision detection. if its to low it means the ball goes to horizontally - this is the cause of horizontal loops (vertical loops are already solved by point 1). There is written something that if the y speed of the ball is below 5.0f then i hard set it to 5.0f at least. (I got the same on bricks in -5 vertical speed and +5 - because the ball can bounce to horizontaly from bricks as well in both ways - slightly going up, slightly going down). then i also hard set the y speed on -5 or +5 respectively (or maybe 10, i’m not sure now).

  3. finally i check absolute ball speed after the bounce. its absolute speed is Sqrt (XspeedXspeed + YspeedYspeed), I want the absolute speed of the ball be always a constant (10 works for me). I just adjust the X and Y speed of the ball by: ballabsolutespeed / 10 * (x and/or y speed).

the code is really a mess and i’m sure it can all be done much more effectively, but…


void OnCollisionEnter2D(Collision2D collision)
//speedXY is bouncing speed in each axis - I just hard set both after the collision (maybe could use trigger instead)
speedX = 10 * (ball.transform.position.x - this.transform.position.x) + 0.5f * (Random.value - Random.value);
speedY = 8f - 7 * Mathf.Abs(ball.transform.position.x - this.transform.position.x) + 0.5f * (Random.value - Random.value);
// speedY is smaller if speedX is faster while speedX depends on x of ball - x of the ship

//Im sure random values are ********, but it was the first that worked for me before I got to know about random range, they’re not even necessary as the variace of bounce is guaranteed by ball bouncin of ships more sideways if it hits off center)

// this sets higher y bounce if its to low - avoids horizontal loop
if (speedY < 5.0f)
speedY = 10.0f;
print(“OPRAVA LODI”);

    // counting absolute speed of the ball
    speedAbs = Mathf.Sqrt(speedX * speedX + speedY * speedY);
    // recount so the absolute speed of the ball is always 10
    speedX = ballspeed / speedAbs * speedX;
    speedY = ballspeed / speedAbs * speedY;
    //ballspeed is a public int (currently set to 10);
    ball.GetComponent<Rigidbody2D>().velocity = new Vector2(speedX,speedY);

//final hard set of ball speed


And similar its done on a brick (I think its stupid and should all be on ball, but i just didn’t know how to find out if there is a collision of the ball with ship or with side of the playspace or with a brick). But well who cares, it works for now and later if I get smarter during the course I can fix it :slight_smile:

Hope it helps!!!
Feel free to ask if it doesn’t work for u.

Hi, thanks!
I will finish the breakout chapter and will sure try to implement it!

Hello Obolus,

I finally got around to fixing the Ball Movement in my clone and used you code to do just that. I’m not exactly sure what you’ve bone in regards to the Mathematics in this code but I’ll just take it on faith because it works a treat :sunglasses:. If it were a bit cooler I might’ve taken the code apart to see the values you were getting and what you have done but it’s well over 35C here and the computer operator is really feeling the heat about now - time to get out of the room :sweat:.

Thankyou for being so kind to make it available for those of us who wanted a little more control over the ball :sunglasses: :sunglasses: :sunglasses:.

Warmest Regards,

Well done. I like the 0 gravity better than -1. It seems to move like the original Arkanoid a lot better this way.

1 Like

Heyyy, I really like this one. We have a greater control over where the ball goes. I really dig your avoidance of the horizontal loop too!

1 Like

ty :)))
(post has to has 10 characters lul)

Yeah. The way you coded it makes me feel like I won by skill and not semi-blind luck.

Hey Obolus,

I can’t seem to get the code to work just right. Can you post your full code? Hope its not too much to ask. Thanks!

hey sorry for late answer, was taking a break :slight_smile:

here u can download the whole project

1 Like

Privacy & Terms