ajewers's Profile
Reputation: 0
Apprentice
- Group:
- New Members
- Active Posts:
- 1 (0 per day)
- Joined:
- 22-October 12
- Profile Views:
- 286
- Last Active:
Oct 29 2012 01:09 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Programing an applet game of Pong
Posted 22 Oct 2012
sabretooth, on 03 December 2011 - 06:17 AM, said:"you have finished your first Game Java applet in a very professionally accepted and methodical way"
Please tell me you are joking.
System resource use is amazingly high due to that while loop which does not even need to be there.
The timer is already polling every 15ms, you don't need the while loop also.
I suggest making the Timer an instance variable and ending the start method at time.start();
This way your actionPerformed can look like this:
public void actionPerformed(ActionEvent arg0) { if(pRight.getScore() == 10) { time.stop(); currentTime = System.currentTimeMillis() - currentTime; } else { //moves the ball ball.move(); //lines the computer paddle up with the ball pRight.setPos(ball.getY() - 35); //checks the ball for a collision checkCollision(); } //repaints the applet repaint(); }
Much more efficient.
Is there any chance you could elaborate on this? Particularly on the 'making time an instance variable' part as the problem i'm having is that time.start() and time.stop() seem to need to be inside the same method
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
ajewers hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
ajewers has no profile comments yet. Why not say hello?