This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Stopping Animation  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I've coded two classes that create an array of the circle object and then move this array of circles by means of redrawing its position in the window.
The circles move clockwise at first and at each move there is a probability, as input by the user, that they are going to change direction. When they change direction the circles cannot again move clockwise. This is what the code below does.
What I need to do to complete the program is to stop the animation when all circles are moving anticlockwise. I've written the following steps, but I am having difficulties coding them in Java.
1. Check the position of each circle (i.e. whether it's moving clockwise or anticlockwise)
2. If it's moving anticlockwise then count the circle.
3. Repeat for all other circles.
4. When all circles are moving anticlockwise stop the animation.
I've figured out that an animation is stopped by the construct if (...) { }.
Can anybody help me code the above four steps into Java?
Below is the code of the two classes.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what do you need help on?
 
Amil Mehmedagic
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to stop the animation when all circles are moving anticlockwise
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Amil Mehmedagic

Stop the animation, when all circles are moving anticlockwise.


Does the program need to detect the circle moving?
So conditions to check the circles moving are required.
And then set the moving value of circles to stop.
Coding? you should code by yourself.

[ April 25, 2004: Message edited by: siu chung man ]
 
Amil Mehmedagic
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My dilemma with this problem is that the instance variable clockwise, which checks whether the circle is moving clockwise or anticlockwise is an instance variable that can only be used in the Circle class, while the loop that controls the movements of circles in array is in the main class.
I think that that particular code, which checks whether the circle is moving anticlockwise, should be in the main method of the Main class.
But how do I check whether the circles are moving anticlockwise with no access to the clockwise variable?
What I want to do is check whether the circle is moving anticlockwise. If it is count it. Loop until all circles are moving anticlockwise, then stop.
But how do do this please, because I cannot access the clockwise variable from the Main method.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!