• Content Count

  • Joined

  • Last visited

  1. Hi all, I'm looking into the possibility of using music to influence what happens in my Phaser.js coded game. Something like what's seen in Beat Hazard, Crypt of the Necrodancer etc. - rhythm interaction with the peaks of intensity/frequency in the music that's playing trigger a response in the game. Is it possible to do this entirely inside Phaser? And if it is, how can I access the properties of the currently playing sound, or even its whole raw sample data, to do it? Thanks a lot!
  2. Thanks! No, I wasn't expecting applyForce to work like that, I never used Box2D anyway. In fact, I'm a physicist, so I would have never mixed the two . What happens is that basically I have my little starship trying to orbit around a planet with gravity going like 1/r^2, but the energy isn't conserved properly and the rocket spirals down to its doom without even completing one loop. I know numerical imperfections are unavoidable, but didn't expect them to be THIS bad. So I was considering making the position a kinematic variable and integrating it on my own, but since that requires more work I was wondering whether it could be avoided. Checking P2.js though it looks like the integration is carried out using the "naive" Euler method (v(t+dt) = v(t) + a(t)*dt; x(t+dt) = x(t) + v(t+dt)*dt;) and there aren't any options for slightly more expensive but more precise methods like Runge-Kutta. So it looks like I'm on my own for this one (either that, or I make an addition to P2 myself...). EDIT: Alright, I found out the issue... it was something really stupid, in fact. I didn't know it, but the body.damping parameter was set to 0.1 by default, thus leading to the body slowly losing kinetic energy... I didn't realize it when it was just moving in vacuum, but as soon as planets were added it became dramatically relevant. Just setting body.damping = 0 solved everything!
  3. Hi all, I've just experienced some trouble with P2 physics. My game uses Newtonian gravity, which requires pretty good integration, and I get some huge errors by just using basic P2 methods (applyForce etc.). My guess is, this is an integration problem, since Newtonian gravity is notoriously hard to integrate numerically. I was considering some fixes, but does anyone know first what integration method does P2 use for its physics step, and if it is possible to change it to a more expensive and precise one? For example, could I do a leapfrog or a Runge-Kutta without editing the source code? I don't know where to find these methods either, I've tried searching the source code but didn't find it. Thanks!
  4. Hi all, I've been playing around with Phaser's P2 physics for a game set in space... I have a very simple starship to which I give a triangular shape with addPolygon and then planets with circle shapes (setCircle). This is an example of the code: //For the playerplayer.body.addPolygon({'skipSimpleCheck': true}, [[this.width/2.0, 0], [0, this.height], [this.width, this.height]]); // A simple triangular shape//For the planetplanet.body.setCircle(radius); After doing a clearShapes() for both. However, the collision seems to be shifted on the player - when it hits on the top, it hits while it's still a few pixels from the surface, while on the bottom, it overlaps a bit before hitting. I suppose this is the consequence of P2 calculating the center of mass of the shape and then overlapping it to the middle of the sprite. Is there any way to avoid/fix this? I tried manually changing player.body.offset but it didn't work. Thanks! EDIT: Ok, I don't know how to tag this as solved but I did find a solution for this. From what I see, yes, P2 finds the center of mass and then automatically overlaps it to the .5, .5 point of the sprite - my solution was to simply increase the sprite's size, giving it some more empty space to shift the center downwards and have it coincide with the place where I wanted the center of mass to actually be. It's a bit rough but I could afford it given that the sprite was very small anyway. Would be nice to be able to avoid this though.
  5. So here's my first game with Phaser.js... and in fact one of the first ever (at least completed ones, and if we don't count the ascii shooter I made with QBasic in middle school XD). This is qPong - a quantum version of the classical game of Pong, where the ball can be in multiple places at the same time and the outcome of a match is determined by both skill and randomness. I took inspiration from some actual physics (I work as a computational scientist, so I know a bit about this kind of simulations and some of that knowledge leaked into my game design ). The description explains it better... anyway it's pretty lackluster but it has good music (thanks to fellow GameJolt user Qwak) and what I hope is an interesting gameplay. I also plan to try and improve the AI a bit in the near future. Enjoy!