What should I tweak in the code to make the ball bounce upward at the beginning?
I am completely lost here and have experimented with numerous ideas without success. I feel like I must be overlooking something simple.
It seems like the key part of the code that needs to be adjusted is related to the if statement for x, but I'm stuck at this point.
function update() {
x += 1;
y += yspeed;
yspeed += gravity;
if ( y >= context.canvas.height)
{
yspeed *= -1;
}
if ( x <= 0 || x >= context.canvas.width)
{
x = (x + context.canvas.width) % context.canvas.width;
}
}
Currently, the ball initiates its bounce in a downward direction. How can I modify it to start by bouncing upwards?