Solved

Random Images

Posted on 1998-07-18
4
238 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 80
Maven Project: Hibernate Dependencies Conflict 10 49
jsp insert to database example 2 59
Java List 4 32
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

713 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