Solved

Random Images

Posted on 1998-07-18
4
224 Views
Last Modified: 2010-03-30
I want to randomly generate and move image of ball  from down to up .
i also want to store every x and y co ordinates of each ball untill it is vanished from top.
0
Comment
Question by:yeda
4 Comments
 

Accepted Solution

by:
tomd012698 earned 50 total points
ID: 1226994
This is the basic plan.  You'll need to fill in some of the gaps, but I think this will help.

1) Create a class that represents the location, and and motion of the ball.
2) Create a Vector within your Applet class to store the balls.
3) Create an animator thread to periodically update the location.

class Ball
{
  public Image _image = null;
  public int _x;
  public int _y;
  public int _xDelta;
  public int _yDelta;
}

class BallApplet extends Applet
  implements Runnable
{
  private Vector _vector = new Vector();
  private Thread _thread = new Thread( this );
  private Image _ballImage = null;

  public void start()
  {
    // Download your image.      
    // Create some balls, and fill in the data members.
    // Start the animation thread.
    // Force a repaint.
  }

  public void run()
  {
    while ( true )
    {
      // Update the positions of all of the balls.
      // When ball leaves the screen, replace with a new one.
      // Force a repaint.
      // Sleep this thread for a while.
    }
  }

  public void paint( Graphics g )
  {
    // Paint all of the balls.
  }
}

0
 

Expert Comment

by:hateli
ID: 1226995
I will try and be in touch with you .

Thanks a lot.
0
 

Author Comment

by:yeda
ID: 1226996
i AM HAVING PROBLEM IN REGENERATING THE BALLS ! PLEASE HELP ME WITH FULL CODE !

0
 

Expert Comment

by:usk
ID: 1226997
I just created the same applet for "hateli".

The applet and source code is located at :

www.cybersite.dk/examples/dropball.htm

(I would like some points for it, if you can use it)


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 35
javap not working 8 43
login jsp example 24 46
hibernate example for saving data 19 37
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now