Today, we're building a procedurally generated, 2D game with PHP. It's a simple game that's focussed around resource gathering on a procedurally generated map. In case you're unfamiliar with that term: it's a map there's generated by code, based on a seed.

So instead of randomness, let's write a hash function: a function that, for any given point and seed, will generate the same value over and over again.

function smooth(float $a, float $b, float $fraction): float { $smoothstep = function (float $fraction): float { $v1 = $fraction * $fraction; $v2 = 1.0 - (1.0 - $fraction) * (1.0 -$fraction); return lerp($v1, $v2, $fraction); }; return lerp($a, $b, $smoothstep($fraction)); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners