ERBarratt Posted November 23, 2018 Share Posted November 23, 2018 Hi chaps, I just thought I'd share something I've been working on: https://github.com/erbarratt/phaser-pointline See it in action: http://sxbx.mountalpine.net I was messing around with trying to get a point to follow lines / collide with lines and have morphed it into a class for dynamic / static objects control (can be integrated into character control classes too). In the repo is pointline.js - the main class, and _player.js, a simple character controller using the objects setup in pointline.js. So far I've implemented: Grounds - flat static lines Slopes - A simple y=mx+b line Walls - Y=0 lines Sticky Walls - For wall jumping etc Platforms (movable grounds, currently x axis only) Simple Gravity All lines have options to check from above, below, or each side so you can make "Jump Through" platforms easily. Collisions are between a dynamic object and N static objects. Whilst I haven't used things like Quad Tress (yet), there is a fair amount of checks to see whether or not to test collisions / ignore objects for example: Is the line on screen Is the dynamic object moving towards the line? Is the dynamic object too far above/below/left/right for it to matter? This is obviously only for phaser 3, and I'm currently using 3.15.1. Next up I'll be adding things like vertical movement for platforms, aforementioned Quad Trees etc. It can be mixed perfectly well with arcade / matter. Let me know you're thoughts / feel free to roast me for my efforts and tell me where I can improve it. Link to comment Share on other sites More sharing options...
Andrew Chen Posted November 24, 2018 Share Posted November 24, 2018 thanks for share http://sxbx.mountalpine.net/ ,btw the tilemap image is very awesome,where did u find this? Link to comment Share on other sites More sharing options...
ERBarratt Posted November 25, 2018 Author Share Posted November 25, 2018 Hi there, All images except for Dog (I just googled) made by me. I can share PSD? Link to comment Share on other sites More sharing options...
ERBarratt Posted November 26, 2018 Author Share Posted November 26, 2018 Hi chaps, I've done some upgrades including: Platforms now move based on a given line - in any direction including vertical (for lifts etc). Added a check on vertical lines meeting slopes at the same pixel, so as not to let the point "stick" to the wall. Link to comment Share on other sites More sharing options...
ERBarratt Posted December 1, 2018 Author Share Posted December 1, 2018 More upgrades: Platforms can now "pause" before reversing movement direction. All lines now have option to pass a callback function on collision (therefor use them as triggers etc) Implement overlappers (dynamic -> dynamic collision checking with 2d rects) For certain line collisions, use 2d box instead of the point slopes now transfer their angle to the sprite All creation methods now take config objects, not just arguments. Config objects have defaults for all values. https://github.com/erbarratt/phaser-pointline I've updated sxbx.mountalpine.net to reflect these new changes. Link to comment Share on other sites More sharing options...
Recommended Posts