waterbearlang / waterbear

Visual block syntax for programming languages
http://waterbearlang.com/
358 stars 88 forks source link

Used a library to detect collision #1243

Closed samuel-massinon closed 8 years ago

samuel-massinon commented 8 years ago

I've tested out collision with this library and it seems to work pretty good.

https://github.com/jriecken/sat-js

Is there a better way to add a library to project or is what I did fine?

dethe commented 8 years ago

No, that's how we add libraries, by adding them to the project in /lib. There is a post about how other projects add libraries here: http://nolanlawson.com/2015/10/19/the-struggles-of-publishing-a-javascript-library/ Just looking at the length of the article may give you a hint why we don't do things that way.

This particular library gives me a sense of deja vu. We used to include SAT. Nothing wrong with that, when I rewrote Waterbear to use custom elements I pulled out everything I could until it could earn its way back in. If we're going to include SAT, perhaps we should use it more (I believe it has a good implementation of vectors, for instance, that we could replace our implementation with).

dethe commented 8 years ago

Do you have any idea how we can write automated tests for collisions?

dethe commented 8 years ago

My comments above are more food for thought than anything else. This looks good. :shipit:

samuel-massinon commented 8 years ago

I'm not sure how easy it would be to replace our current vector implementation with SAT but I could look into it more. I'm wrestling with trying to make our current code work with SAT but it might be a good idea to try to replace some parts of it with SAT instead.

For testing, I think we could easy make up objects, do the math to see if they collide or not and run the tests according to that.

samuel-massinon commented 8 years ago

Forgot to reference this issue https://github.com/waterbearlang/waterbear/issues/1207