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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners