Solved

Random Images

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse package explorer vs project explorer view 2 79
Java - Why doesn't this JFrame work 3 41
Java Loop 6 48
Java Options in Zimbra Server 2 44
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

911 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

25 Experts available now in Live!

Get 1:1 Help Now