# Phaser Coding Tips 1&2 Revisited: Pixel based Physics

**URL:** <https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194>\
**Category:** Examples\
**Created:** [August 21, 2022, 5:53pm UTC](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194 "2022-08-21T17:53:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedarcantab](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/cedarcantab/32/6120_2.png) [@cedarcantab](https://phaser.discourse.group/u/cedarcantab)\
**Post date:** [August 21, 2022, 5:53pm UTC](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194/1 "2022-08-21T17:53:34Z")

</div>

Of all my posts here, my post [here](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-creating-a-game-like-tanks-worms/11329) generated the most response - I guess I am not the only one interested in this esoteric field of manipulating the canvas at pixel level…  
 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/c/c4bf0fca3b92083c58f6e75b0e91ae99bf9c559b.png)

I have been playing around with the canvas texture class some more and have come up with this simple demo of balls bouncing on destructible (i.e. non-flat, non-axis aligned) terrain. To get the ball bouncing off angled terrains, I have adopted a very simple algorithm to calculate the surface/collision normal, which is described in my blog [here](https://cedarcantab.wixsite.com/website-1/post/phaser-coding-tips1-2-revisited-part-4-pixel-based-physics).

The example code can be accessed below. Click mouse to generate new bombs.  
[Phaser Coding Tips 1-2 Revisited: Pixel Based Physics (codepen.io)](https://codepen.io/cedarcantab/pen/yLKZjyw)

As an aside, I have also created this little Lemmings like demo - in terms of the logic, this not much different from my Donkey Kong demo, but I would be grateful for any feedback or comment if anyone is interested in this sort of stuff (and add more features, as I ran out of energy).

[Phaser Coding Tips 1-2: Lemmings (codepen.io)](https://codepen.io/cedarcantab/pen/OJvdZyv)

---

<div class="post-metadata">

**Author:** ![rich](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/rich/32/4_2.png) [@rich](https://phaser.discourse.group/u/rich)\
**Post date:** [August 22, 2022, 5:45pm UTC](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194/2 "2022-08-22T17:45:18Z")

</div>

The bombs demo is lovely 🙂

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [September 9, 2022, 4:18pm UTC](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194/3 "2022-09-09T16:18:39Z")

</div>

https://codepen.io/samme/embed/preview/YzagLmY?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=YzagLmY

I added digging (click) and exploding (shift-click).

---

<div class="post-metadata">

**Author:** ![cedarcantab](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/cedarcantab/32/6120_2.png) [@cedarcantab](https://phaser.discourse.group/u/cedarcantab)\
**Post date:** [September 18, 2022, 5:57am UTC](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194/4 "2022-09-18T05:57:30Z")

</div>

Wow! Thank you adding the feature! It’s almost hypnotic watching those lemmings dig!
