This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for Ping-Pong

Return to Ping-Pong

yedefeiyedefei

2012/8/7

well coded!
A new version of this scenario was uploaded on Wed Aug 08 09:16:24 UTC 2012
Thanks! My new update has a short wait time built in whenever somebody gets a goal.
A new version of this scenario was uploaded on Thu Aug 09 11:50:43 UTC 2012
JiniceJinice

2012/8/9

I WON!!!!
JiniceJinice

2012/8/9

YAAA!!!!!!!!! WOOOOOOOOOOOOOOOO YA!!!!!!
JiniceJinice

2012/8/9

WINNER WINNER CHICKEN DINNER!!!!!!!!!!
yedefeiyedefei

2012/8/10

where is the source?
CockyCocky

2012/8/12

Ich kann es nicht öffnen :(
CockyCocky

2012/8/12

Ich kann es nicht öffnen :(
A new version of this scenario was uploaded on Wed Aug 15 07:49:16 UTC 2012 fixed bug when bouncing off the top.
A new version of this scenario was uploaded on Tue Sep 04 19:20:48 UTC 2012
A new version of this scenario was uploaded on Sat Sep 15 21:22:05 UTC 2012 Improved color layout
A new version of this scenario was uploaded on Sat Sep 15 21:23:11 UTC 2012 Improved color layout
Very nice game but there is one bug I think: Sometimes when the ball hits a wall it just goes along the wall and dosen't get away there. I think you could do this with a loop in your method which tells the ball to turn when he hits the wall, because the problem probably is that the ball hits the wall again and again and again. if you use: while (getY() < 10) { //or another number. I don't know the real number from your game. move(1); //or if this doesn't work use setLocation(getX(), getY()+1); } And maybe you could include a better artificial intelligence This one only follows the ball. And if I hit the ball with a steep angle it doesn't get the ball most time. But all in all a very nice game.
I made an update fixing the problem a while ago. I thought I had fixed it.. Good thing you said it then! And I will see if I can improve the AI.
danpostdanpost

2012/9/18

The easy fix for the wall-hugging problem is using a double condition as follows: if (ySpeed > 0 && getX() > getWorld().getHeight() - 11) ySpeed = -ySpeed; if (ySpeed < 0 && getX() <= 11) ySpeed = -ySpeed; Of course, I chose 11 as an arbitrary number and you should adjust it to the appropriate value for the size of your ball. The two statements can be combined into one larger 'if' by wrapping each set of conditions in parenthesis and ORing them together. if ((ySpeed > 0 && getX() > getWorld().getHeight() - 11) || (ySpeed < 0 && getX() <= 11)) ySpeed = -ySpeed;
To make the ball move, I used the Actor method move(int), but I get your point. to mirror an objects direction I'll just change the angle using the methods i already created.
A new version of this scenario was uploaded on Wed Sep 19 13:45:56 UTC 2012 Fixed color bug