fasiy / rokon

Automatically exported from code.google.com/p/rokon
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

MathHelper.intersects(sprite, sprite) bug #105

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Sprite box1, box2;
box1 = new Sprite(500, 20, 75, 146);
this.add(1, box1);          
box2 = new Sprite(500, 250, 56, 163);
this.add(1, box2);
Log.d("Intersects", "" + MathHelper.intersects(box1, box2));

What is the expected output?

False.

What do you see instead?

True.

What version of Rokon are you using?

Trunk (2.0.3).

On which version of Android are you experiencing this?

Android 2.1.

Please provide any additional information below.

The problem seems to be only with specific values, so it doesn't happen in all 
cases. 

Original issue reported on code.google.com by necrotic...@gmail.com on 9 Jul 2010 at 11:20

GoogleCodeExporter commented 8 years ago
Any expansion on 'specific values'?

Can you test to see which ones?

Original comment by rtaylor205@gmail.com on 10 Jul 2010 at 6:59

GoogleCodeExporter commented 8 years ago
Well, the ones in my example above are representative for the issue.

Original comment by necrotic...@gmail.com on 11 Jul 2010 at 6:56

GoogleCodeExporter commented 8 years ago
OK, I think I found the problem: line 182 in MathHelper.jave contains a silly 
mistake:

return rectOverlap(sprite1.getX(), sprite1.getY(), sprite1.getX() + 
sprite1.getWidth(), sprite1.getX() + sprite1.getHeight(), sprite2.getX(), 
sprite2.getY(), sprite2.getX() + sprite2.getWidth(), sprite2.getY() + 
sprite2.getHeight());

note the sprite1.getX() + sprite1.getHeight()

this should be

return rectOverlap(sprite1.getX(), sprite1.getY(), sprite1.getX() + 
sprite1.getWidth(), sprite1.getY() + sprite1.getHeight(), sprite2.getX(), 
sprite2.getY(), sprite2.getX() + sprite2.getWidth(), sprite2.getY() + 
sprite2.getHeight());

Original comment by necrotic...@gmail.com on 13 Jul 2010 at 7:46

GoogleCodeExporter commented 8 years ago
necroticist was right.

lack of unit tests.

Original comment by wuas...@gmail.com on 22 Jul 2010 at 7:21

GoogleCodeExporter commented 8 years ago
Thanks, dumb mistake

Original comment by rtaylor205@gmail.com on 25 Jul 2010 at 8:38