# Coefficient of restitution

**URL:** <https://forum.makecode.com/t/coefficient-of-restitution/902>\
**Category:** Arcade\
**Created:** [December 16, 2019, 2:00pm UTC](https://forum.makecode.com/t/coefficient-of-restitution/902 "2019-12-16T14:00:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [December 16, 2019, 2:00pm UTC](https://forum.makecode.com/t/coefficient-of-restitution/902/1 "2019-12-16T14:00:19Z")

</div>

Has there been any thought about allowing either a global or a per tile [coefficient of restitution](https://en.wikipedia.org/wiki/Coefficient_of_restitution) for control over elasticity on wall bouncing?

Different issues, but on the subject of inelastic bounces I’ve previously noted/raised [Mega-elastic collisions](https://forum.makecode.com/t/mega-elastic-collisions/815).

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [December 17, 2019, 7:00pm UTC](https://forum.makecode.com/t/coefficient-of-restitution/902/2 "2019-12-17T19:00:07Z")

</div>

Our physics engine is more of an “arcade physics” engine; we just reverse the velocity if you collide with a wall (i.e. vx becomes -vx). The code is [here](https://github.com/microsoft/pxt-common-packages/blob/master/libs/game/physics.ts#L419) for reference.

I don’t think we have any plans currently for a “real physics” engine, but we made the engine swappable if anyone is interested in making their own. It would probably be doable to find a simple JS or C++ physics engine and port it over.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [December 17, 2019, 7:03pm UTC](https://forum.makecode.com/t/coefficient-of-restitution/902/3 "2019-12-17T19:03:51Z")

</div>

BTW if you’re looking through the physics engine, you might notice the math looks a little strange. It’s because we use [fixed point arithmetic](https://en.wikipedia.org/wiki/Fixed-point_arithmetic) to speed things up on hardware. Anywhere you see Fx or Fx8 in the code, that means it’s a fixed point number.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [December 17, 2019, 10:51pm UTC](https://forum.makecode.com/t/coefficient-of-restitution/902/4 "2019-12-17T22:51:10Z")

</div>

Thanks.

On subject of collisions there’s also a peculiarity in [Mega-elastic collisions](https://forum.makecode.com/t/mega-elastic-collisions/815) with things bouncing higher over time. Do you know why that is? And low velocities (\<1) behave very strangely, I tacked that on the end of that thread.
