Results 1 to 2 of 2
- 12-08-2009, 01:43 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 1
- Rep Power
- 0
Bouncing ball program... having problems..
Java Code:import java.awt.*; import javax.swing.*; import java.awt.event.*; public class PracticalExam extends JApplet { int x = 70; int y = 100; int xVelocity = 5; int yVelocity = 5; public void start() { System.out.println("firing start..."); Timer timer; final int FREQ = 33; timer = new Timer(FREQ, new ActionListener() { public void actionPerformed(ActionEvent evt) { repaint(); } }); timer.start(); } public void paint(Graphics g) { if ( (x > 350) || (x < 50) ) { xVelocity = -xVelocity; } if ( (x < 350) || (x > 50) ) { g.setColor(Color.white); g.fillRect(x,y,30,30); x += xVelocity; y += yVelocity; g.setColor(Color.green); g.fillRect(x,y,30,30); } if ( (y > 250) || (y < 50) ) { yVelocity = -yVelocity; } if ( (y < 250) || (y > 50) ) { g.setColor(Color.white); g.fillOval(x,y,50,50); x += xVelocity; y += yVelocity; g.setColor(Color.red); g.fillRect(x,y,50,50); } } }
I was making a progam that a ball bounces the wall.
My purpose was to make the ball change its shape and color when it bounces.
But I am having problems...
Please help me editting...... emergency T^T
- 12-08-2009, 04:16 PM #2
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
[SOLVED] Bouncing ball with polar coordinates
By Ypsilon IV in forum New To JavaReplies: 4Last Post: 04-22-2009, 12:19 AM -
How to create a bouncing ball animation
By Java Tip in forum java.awtReplies: 0Last Post: 06-21-2008, 08:43 PM -
high bouncing ball
By bouncingball in forum Reviews / AdvertisingReplies: 1Last Post: 06-19-2008, 11:21 AM -
bouncing ball issue
By adam405 in forum New To JavaReplies: 1Last Post: 03-18-2008, 03:48 AM -
Problem deleting ball from bouncing ball app
By adlb1300 in forum New To JavaReplies: 2Last Post: 12-03-2007, 09:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks