replit / kaboom

💥 JavaScript game library
https://kaboomjs.com
MIT License
2.66k stars 224 forks source link

Incorrect documentation and unusable feature #588

Open a-a-GiTHuB-a-a opened 2 years ago

a-a-GiTHuB-a-a commented 2 years ago

Version

2000.2.9

What browsers are you seeing the problem on?

Microsoft Edge

What happened?

The documentation states that the Shape type is a union of strings. However, the code says it is a union of classes. On a related note, using a Circle or Polygon for the shape option of area() does not do anything.

What's the expected behavior?

The documentation should reflect the type, and area() should support shape.

Minimum reproducable code

...
add([
  rect(16, 16),
  area({
    shape: new Circle(vec2(0, 0), 1),
  }),
  origin("center"),
]);
...

Live demo

No response

l8doku commented 2 years ago

The code for version 2000.2.9 shows that Shape is a union of strings

https://github.com/replit/kaboom/blob/v2000.2.9/src/types.ts#L3815

a-a-GiTHuB-a-a commented 2 years ago

But the area() function always returns a rect. https://github.com/replit/kaboom/blob/v2000.2.9/src/kaboom.ts#L3651

l8doku commented 2 years ago

Yes, only rectangular collisions work in the version 2000.2.9. But as you mentioned in the original post, it's different in master. I imagine it will work very differently in the next release, and for the current release the only potential fix would be to remove other shapes from the documentation.