• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BrickBreaker code error

 
Mike Barry
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

rc
 
Maneesh Godbole
Saloon Keeper
Posts: 11325
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic