-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks