Question: Make a ball bouncing. The ball can be an image (Redball.png as attached). You are welcome draw your own, which might be better. You are

  1. Make a ball bouncing. The ball can be an image (Redball.png as attached). You are welcome draw your own, which might be better. You are expected to submit three files: ball.html, ball.css, and ball.js. You can access its tyle attribute by using document.getElementByID(ball). You can create a .css for the html so that the ball and its box look like this:

 Make a ball bouncing. The ball can be an image (Redball.png

The ball should start bouncing as soon as the web page is loaded (look up window.onload). E.g. window.onload = function()

Write two separate .js file and make sure your code can do the following:

  1. (4pts) The ball keep bounces at a constant speed without decay( constant bouncing).

  1. (3pts) The ball bounces but the speed decays to zero.

  1. (3pts)The ball bounces but also moves to the right end of the wall and disappears.

  1. (5pts) Modify your code so that when you press the Z key, the ball slows down, and when you press the X key, it speeds up. Once that is working, use C to make the ball smaller and V make it larger.

Hint: the animation is created by changing the position of the ball.

You might find the following code snippets helpful:

var ball = document.getElementById("ball");

ball.style.top = ballY + "px";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!