shape shifter


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: shape shifter

  1. #1
    Join Date
    Aug 2002
    Posts
    1

    Unhappy shape shifter

    Just wandering if you could help me out.
    I have to write an applet that allows the user to select from either a
    square or circle, either of which could be red,green or blue. The user
    then has to predict how many times thee object will bounce off the sides
    of the frame. Every time the object hits the side the prediction they said
    is decremented by 1. I have no real idea how to do this.

  2. #2
    Join Date
    Aug 2002
    Posts
    2
    I don't know all the answers but I do know that you will need to implement the following things.

    1. a mouse Listener, also probably a MouseMotionListener interface.

    2. an collision detection scheme. This would test if two bojects are touching. This is usually done using bounding rectangles.

    3. You need a bounding rectangle to represent each wall of the screen. Test for collision with these and your shapes.

    4. When you use a mouse listener you must implement each method that make up a mouse listener. Example
    mouseClicked(MouseEvent e) {}
    //all the following have
    //MouseEvent e inside ()

    mouseEntered()
    mouseExited()
    mousePressed()
    mouseReleased()

    //MouseMotionListener methods
    mouseDragged(MouseEvent e)

    mouseMoved(MouseEvent e)

    I hope this helps. I got most of it from Java 2 Game Programming by Thomas Petchel.


    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center