Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Pong: Ricochet off Paddle Issue

  1. #1
    Member Staticity's Avatar
    Join Date
    Jul 2011
    My Mood
    Thanked 5 Times in 5 Posts

    Default Pong: Ricochet off Paddle Issue

    I've had this old program laying around from when I first started programming, so I decided to optimize it up a little bit.. Everything works great now.. However, I can't get the stinkin' ball to bounce off the paddle. It does funny things sometimes I start up the program, and does absolutely nothing other times I start it (I can go into further detail if needed).. Just to triple check my logic.. here's the method:

    	public void checkCollision(){
    		if(ball.x == 5 && (ball.y > paddle1.y && ball.y < paddle1.y+63))
    			ball.xspeed = -ball.xspeed;
    		if(ball.x == WIDTH - 20 && (ball.y > paddle2.y && ball.y < paddle2.y+63))
    			ball.xspeed = -ball.xspeed;

    It may have something to do with my use of OOP. I can post more code if necessary
    Simplicity calls for Complexity. Think about it.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Pong: Ricochet off Paddle Issue

    You've marked this as SOLVED. I presume you no longer need help?

    If you do need help, you'll want to provide an SSCCE that demonstrates exactly what you're doing.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Getting my paddle to move left and right in a straight line-STUCK
    By warnexus in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 20th, 2011, 08:06 PM
  2. Array issue
    By Mini83 in forum Collections and Generics
    Replies: 5
    Last Post: August 18th, 2011, 09:18 AM
  3. Possible threading issue
    By Kerr in forum Threads
    Replies: 3
    Last Post: March 6th, 2011, 05:24 PM
  4. breakout paddle algorithm
    By Brain_Child in forum Algorithms & Recursion
    Replies: 0
    Last Post: December 30th, 2009, 05:24 AM
  5. [SOLVED] Fixing of bug for Pong game
    By phoenix in forum What's Wrong With My Code?
    Replies: 11
    Last Post: July 14th, 2009, 01:19 PM