Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by TommyBs

Hi,

Recently purchased impactjs and playing around with the pong demo. What I want to do is increase the puck speed every time it collides with a wall or the paddles.

Does anyone know how I would achieve this?

thanks

1 decade ago by dominic

You can overwrite the .handleMovementTrace() and .collideWith() methods in your puck entity. The first one is called for collisions with the collision map (i.e. the walls), the second is called for collisions between entities.

Just increase the puck's velocity by a certain factor each time it collides. E.g.:
// double the speed
this.vel.x *= 2;
this.vel.y *= 2;

Also make sure to set a higher .maxVel.* for the puck, to allow greater speeds.
Page 1 of 1
« first « previous next › last »