przemoo83 Posted July 14, 2017 Share Posted July 14, 2017 Hi I'm planning to develop a simple HTML5/Phaser game. The idea seems very simple but I'm not sure if my choice of tools is right the goal of a game is to draw a given shape as precise as possible. So for example we have a star which is moving alowly to make things a little bit more challenging and player need to draw a line around it as close to its edges as possible. The farther they draw from the edges the lesser points they get. Visualisation below So I thought that I should a physics engine for this to detect collision with the body of this shape and since shapes will be very different and complicated I cannot use Arcade for this. So i though about P2 physics but isn't that overkill for such a simple game? Maybe there's simpler and more efficient solutions to achieve the desired effect? Any advice will be appreciated Link to comment Share on other sites More sharing options...
samid737 Posted July 14, 2017 Share Posted July 14, 2017 Hi. Here is an example of something you could use using arcade physics: The idea is to first draw any primitive shape you like using bitmapData and interpolation. The shapeData array can be modified to create any shape you like. Then in your plot function you evenly distribute dots (with physics) along your shape. Then you create three to four "mouseBodies" that follow your mouse and collide with the dots. this way you can determine how far off you are from the actual shape. The collision checks are then done and based upon which "mouseBody" is colliding, so you add or even subtract score (see example). Notice that the trail is drawn using rendertextures (example), but this is certainly not a must. You can also draw your mouse trail using graphics. You could also stick to rendertextures, but make your own sprite (simple gradient circle made in photoshop, 64x64) and replace it with the gameboy. You will probably have a nice looking cloud trail. A final note, the actual primitive shape can also be drawn as a polygon using graphics. These are all implementation details, but maybe it will give you more ideas for your own game... przemoo83, ncil, coelacanth and 1 other 4 Link to comment Share on other sites More sharing options...
przemoo83 Posted July 14, 2017 Author Share Posted July 14, 2017 That's a great answer and solution from you. Thanks so much! samid737 1 Link to comment Share on other sites More sharing options...
Recommended Posts