Question About Game Idea (Breakout / Arkanoid)

I think here was my mistake, it must be > here

(you had bally<recty+40) { and this applies almost always)

AND it works only when you attach the if-clause before

if (bally-ballr/2>height) {
    reset();
  }

to the paddle-if-clause by …else if.

Then, we check for the paddle only when it’s not hitting the screen border

Remark 1

you had also

        yspeed *= -4;

which means the speed gets 4 times faster which is way too fast;

        yspeed = -4;

is enough.

Remark 2

You don’t take into account the radius add it upon checking the screen borders etc.

Remark 3

instead of working with a fixed speed, try random values.

xspeed = random(2,6); 
yspeed = random(2,6);

Reflection

This means for negative values instead of yspeed = -4; say
yspeed = - abs (yspeed); // always negative

for positive value: yspeed = abs (yspeed); // always positive

abs() just means give me the positive value from whatever comes in (the absolute).

Remark 4

Consider to make the edges of the paddle round and to change the kind of reflection.
When the ball hits the edge from the right, also the speedx could change e.g.

1 Like

it works! thanks for the help! i missed that *= im not really sure why i added it. i think the rest of what i am going to do will be easier now that ive finished this part. thanks again!

1 Like

please consider my remarks

2 Likes
2 Likes