Solved

Random Images

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

791 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