# 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:** 1\
**Showing post:** 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)

---

_[View the full topic](https://phaser.discourse.group/t/phaser-coding-tips-1-2-revisited-pixel-based-physics/12194)._
