Question: Javascript P5 animation Problem: 2. Moving a Ball Game Develop a simple game where the objective is to control the movement of a circle such

Javascript P5 animation Problem:

2. Moving a Ball Game

Develop a simple game where the objective is to control the movement of a circle such that it will eventually reach a goal represented by another circle. The movement depends on the relative location between the mouse cursor and the center of the canvas. The more the cursor is to the right or left, the faster the circle is moving toward the right or left.

Read and study the template code:

http://alpha.editor.p5js.org/doubleshow/sketches/H1kHf0ULG In the template code, the green circle (ball) only moves in 1D along the x dimension. The movement speed is constant, rather than variable. Your task is to add the following enhancements:

The ball (green circle) can be controlled to move in 2D along both the x and y axes.

The speed is variable and proportional to the distance from the center; the further away, the faster the ball moves.

The goal circle should provide visual feedback; when the goal is reached, the goal circle should change its color.

The goal circle's location and radius should be random (currently it's hard coded).

The canvas should display your name.

P5.javascript reference: https://p5js.org/reference/

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!