Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Eclipse with javafx application: 1. Create a class called ParticleController in the edu.kettering.cs101 package that extends javafx Application 2. In the ParticleController implement the

Using Eclipse with javafx application:

1. Create a class called ParticleController in the edu.kettering.cs101 package that extends javafx Application 2. In the ParticleController implement the main method to launch the app 3. In the ParticleController implement the start method 4. In the ParticleController create an array of 20 Circle Objects 5. Create the Circle Objects in the start method and add the circles to the root to be displayed 6. At the end of the start method add the following code to run animation Make sure to declare the required variables if (thread == null) { thread = new Thread() { public void run() { while(true) { if (running) { runLoop(); } try { Thread.currentThread().sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } } }; thread.start(); 7. Implement the runLoop method in the ParticleController class 8. When creating the circles initialize the radius to 40. Randomly initialize the X and Y positions 9. Create a double array for storing the circle x velocity 10. Create a double array for storing the circle y velocity 11. Randomly initialize the x and y velocity values between -20 and +20 12. In the runLoop method adjust the corresponding circle x and y position by adding the velocity values 13. Create a collisionCheck method which is called at the end of the runLoop method 14. In the collisionCheck method loop through each circle (i), then loop through all other circles (j) Calculate the distance between the 2 circles. If the distance is less than 80, then reverse and reduce (0.8) both the x and y velocity

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the different techniques used in decision making?

Answered: 1 week ago