• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stopping Animation

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what do you need help on?
 
Amil Mehmedagic
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic