Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Bounce and check bounce issues
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
compmaster




PostPosted: Mon May 17, 2010 7:39 pm   Post subject: Bounce and check bounce issues

I'm trying to make a pong game on Turing for school. I have major issues with wall bounces and paddle bounce detection issues.

Please enable air hockey mode to get these bugs to appear.

WSAD to move first paddle, arrow keys for the second paddle.

I'm trying to get the ball to bounce off walls for 0<y<150 and 250<y<400

The paddle issue is when you move the paddle forward to push the ball, it sometimes make the ball go backwards. I know why it happens, because each movement moves the paddle 5 pixels, and the ball may only move 1-2 pixels at a direction every time it moves. So it creates a "teleporting" effect, where the paddle is suddenly behind the ball. I don't know how to fix it without making the paddle move very slowly (1 pixel at a time).

I have NO idea why the wall bounce detection doesn't work. The code seems perfect.

Thanks so much.



pong.zip
 Description:

Download
 Filename:  pong.zip
 Filesize:  272.92 KB
 Downloaded:  113 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
USEC_OFFICER




PostPosted: Tue May 18, 2010 11:44 am   Post subject: RE:Bounce and check bounce issues

How wide is the paddle? It may be moving far enough that the ball thinks it is on the other side of the paddle, with clear results.
compmaster




PostPosted: Tue May 18, 2010 3:14 pm   Post subject: Re: RE:Bounce and check bounce issues

USEC_OFFICER @ Tue May 18, 2010 11:44 am wrote:
How wide is the paddle? It may be moving far enough that the ball thinks it is on the other side of the paddle, with clear results.


I just realized the paddle has a width of 1 pixel... I think that's the problem.

Now just the wall bounce problem to solve...
USEC_OFFICER




PostPosted: Tue May 18, 2010 7:37 pm   Post subject: RE:Bounce and check bounce issues

Glad I can help.
compmaster




PostPosted: Tue May 18, 2010 8:51 pm   Post subject: Re: Bounce and check bounce issues

Actually, the width is considered in the checkpaddlebounce procedure. The code wasn't written by me, so I don't know what to do.

The paddle bounce detection is giving me hell.

The wall bounce is now fixed.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: