-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line of Sight (Ray Tracer) #285
Comments
Thank you very much for the link ! It’s effectively a nice feature to add, however as part of the next 1.0.0 release we do however plan to rewrite the whole collision mechanism using a SAT algorithm, and to use polygon shape object to design the collision layer, which means that we won’t have anymore the current tile based collision as use in this same article. Which mean raytracing can be added but with a slight different technique :) |
Hi Olivier Some related algorithms: http://www.redblobgames.com/articles/visibility/ http://blogs.msdn.com/b/ericlippert/archive/2011/12/12/shadowcasting-in-c-part-one.aspx Thanks! |
I did a lot of this work for the dynamic lighting in Alienauts : http://blipjoy.github.io/alienauts/public/index.html#debug Specifically, I used the vector methods provided by Chipmunk-js. Anyway, I am going to need this functionality in Sprung Fever, which does not use Chipmunk-js. So I can't just piggyback off its vector math support. I don't know if an API can be specified for these things without being too restrictive. Providing the math functions and allowing experienced developers to make use of them is the best approach I know of, as far as interface. |
hope that helps, i follow the guy on twitter: https://twitter.com/deepnightfr he's won a couple LD's and such :) |
Hi @parasyte The idea is implement a "generic" function with check for object collide between Point A and Point B (returning a array of objects maybe). It is up to the developer to implement a logic to see if the single object that collided is Point B, which would mean a direct target. In you game Sprung Fever, if one of the girls is on the other side of the wall, the indicator increases, ie you only checks the distance between the player and enemies, ignoring obstacles between them ;) |
I wrote a bresenham plugin for my LD48 game, live on Twitch. 😖 https://github.com/blipjoy/kungfustar/blob/gh-pages/public/lib/plugins/melonham.js The video shows how I used it. Not the way I imagined in the final game (I'm not going to have time for the rope collisions with the world. Maybe after compo) |
Nice, and I love the name of the plugin :) |
@parasyte Nice plugin, works well for trace collisions with Tiled Collision Layer. But if instead of using the Tiled Collision Layer I need to use Tiled objects, how to check? Or how to get which ObjectEntity is in a certain coordinate of the Tiled map (i.e detect dynamic entities that is not defined in the collision layer)? |
i guess this one should become easier to implement with the improvements in 1.1.0 (SAT/Quadtree) ? |
Well, it's still going to be kind of tricky. Assuming your shapes have a minimum width/height (like 10px, for example) you can use that as the step size for the bresenham line generator. That way you're not checking for collisions on every pixel (slow!) but you can still use the polygon hit detection and response vector from SAT to get pixel-perfect collisions along any straight line segment. |
Hi Guys, What do we do with this one now ? I mean that we show how this is possible using the new collision system, what shall we discuss here ? Add this as a "standard feature" in the engine ? |
Add it as a "standard feature" in the engine 👍 |
It's good to have, but this is how feature creep sets in. Make it a module add on! #212 |
For tracking with a working example: http://aaschmitz.github.io/melonjs-improved-platformer/ @parasyte Yes, increase the melonJS file size. But, it's a nice feature, and the more features you have, the more complete and distinct is the engine, helping developers :) |
I agree in part. The point of the modular approach is to provide that completeness without sacrificing usability. It's like a Swiss Army Knife compared to a Switch Modular Knife; The Swiss Army Knife has fixed utilities, and some of them are big and bulky. The Switch Modular Knife can be resized to fit your needs, and the attachments are interchangeable and configurable; you can even make it big and bulky if that's what you really want. |
…ementation this one was basically coming for free after we added Quadtree + SAT collision implementation in melonJS. it can probably be improved or the API tweaked a bit, but it's pretty simple to use already : just cast a line, and get in return an array of intersecting entities.
this one was basically coming for free after we added Quadtree + SAT collision implementation in melonJS, not sure why we did not do it back then, except probably because we have too many tickets, and not enough people closing them :P :P :P |
Given a point x and a point y in the map, we can see if it has a direct view between them without colliding with other objects or solid tiles.
Something like this article:
http://www.codeproject.com/Articles/15604/Ray-casting-in-a-2D-tile-based-environment
This is a fine complement to be used in conjunction with the new collision system #103 ;)
Thanks!
The text was updated successfully, but these errors were encountered: