This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes BrickBreaker code error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BrickBreaker code error" Watch "BrickBreaker code error" New topic

BrickBreaker code error

Mike Barry

Joined: Oct 06, 2011
Posts: 1
Hi so I'm new to this and I'm using BlueJ and I'm trying to make it so that when the ball his a block on the screen it goes in a different direction instead of just going through it.
Anyway, here's my code,
(The error is "operator && cannot be applied to boolean, double" for line 59)

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Mike Barry wrote:
else if(ball.overlaps(brick) && (speed = -Y_SPEED))

You probably mean "speed == -Y_SPEED" -- one = means assignment, you use == for determining whether two things are equal.

I didn't read the rest of the code.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10828

Welcome to the Ranch.
In future, while posting code, please UseCodeTags. I have added them this time to your original post. As you can see, they make the code much more easier to read and understand.

Ralph is correct.
= is an assignment operator where as == checks for equality

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: BrickBreaker code error
It's not a secret anymore!