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

1 decade ago by LaserBeam


If the player walks towards an entity and collides he has to stop. I achieved this with: this.maxVel.x = 0. For whatever reason trying to set the vel to 0 doesn't work. Further I unbind keys, except one 'V' (which is not one of the direction buttons). Pressing this one I reset the previous value of maxVel. Even though I am not pressing any button the player continues to walk into the direction he walked before he was stopped. The only way to make him stop is to press the button for the direction he is walking.

Any idea how to make him not continuing walking after pressing the button, so he only continues walking again after I press one of the direction keys?

Another thing that is strange, maybe someone has seen something like this before: The collision with the first entity can be like described above resolved by pressing the button 'V'. However for all the other entities that follow this button has to be pressed twice, but there are no additional loops, etc in the code. Also the result is always the same not depending which entity is colliding with the player first. Any idea someone?

1 decade ago by Jerczu

Paste your entity code

1 decade ago by drailing

add friction to your entity :)

1 decade ago by Arantor

Well, friction is one method, another is to reset the vel figures when input isn't pressed.

What I find myself doing is something much as:
if (ig.input.state('left'))
   this.vel.x = -100;
else if (ig.input.state('right'))
  this.vel.x = 100;
  this.vel.x = 0;

Also be sure to check the browser for errors, I spent a lot of time today chasing down a stupid bug in some code that was causing errors - and one of the side consequences is that it treated it as if input was continually being pressed, even though it was totally unrelated code in the main game's draw routine, not even entity related.

1 decade ago by LaserBeam

I have the code stated above but it does not help. The other solution with the friction resulted in a strange behavior of the player.

So, I started a total new approach (again). This time I have to press the button first and everything else is handled afterwards; in this case also vel.x works.

Thanks guys for your help!

@Arantor: Thanks for the timer tutorial. It has been very useful in the last two weeks.
Page 1 of 1
« first « previous next › last »