would this work?

Page 1 of 1

2 Replies - 379 Views - Last Post: 21 March 2012 - 02:02 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=271684&amp;s=d8aaf515be882c1b6751397e4c0bc360&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 blacksakura

Reputation: 0
• Posts: 27
• Joined: 12-March 12

would this work?

Posted 20 March 2012 - 12:54 AM

would this piece of collision code work?

```	if ((bally + ball_width) && (ballx + ball_height) >= (leftpaddley + paddle_width && leftpaddlex + paddle_height))
ball = 0;

```

Is This A Good Question/Topic? 0

Replies To: would this work?

#2 Mylo

• Knows all, except most.

Reputation: 265
• Posts: 747
• Joined: 11-October 11

Re: would this work?

Posted 20 March 2012 - 03:01 AM

I'm sure that is not compilable. You are using logical operators between numbers. They should be evaluating booleans.

Edit: Not java forum, sorry.

However, it shouldn't work. I believe in C++ a non-zero number equates to true. True/False is above or equal to True/False. Also, you place ballY with width, and x with height which makes no sense.

What you need to do is:

```if (ballX + ball_width >= paddleX)
// this would be if the ball is going right and hits the paddle. If you are going left, you will need to account for the paddles width, but not the balls width. This is the same for up and down.

```

This post has been edited by Mylo: 20 March 2012 - 03:12 AM

#3 blacksakura

Reputation: 0
• Posts: 27
• Joined: 12-March 12

Re: would this work?

Posted 21 March 2012 - 02:00 AM

thanks heaps that helped alot =D

just got back from uni after finishing my pong clone = D i am pretty happy with the results

if anyone wants it i can upload it =D