panasupermarket.blogg.se

How to make crossy road on scratch
How to make crossy road on scratch





how to make crossy road on scratch

When generating a new footpath, randomly select from these chunks and snap them end-to-end like LEGO bricks. Pre-author a bunch of "chunks" of footpath in various thicknesses with a solvable route through it. You're guaranteed that your reserved solutions still work, possibly in addition to some other solutions if you've left gaps in the non-reserved tiles. Now, randomly fill some/all of the non-reserved tiles with obstacles. Mark each tile these random paths touch as "reserved". Start by picking one or more solution paths - say taking a few biased random walks from the passable tiles from the previous footpath, until they reach all the way to the far side of this footpath. If passable results are rare, you might spend a lot of time re-generating only to fail.įix it: carve out one or more solution paths somewhere, either picking a random column to bulldoze to passable space, or selectively deleting an obstacle (eg at the thinnest point) Try again from scratch! This approach is easy, but relies on your randomization routine already having a good probability of making a passable result by luck. If your flood fill reaches the far side, then there's at least one passable route.

how to make crossy road on scratch

Generate the trees/rocks randomly, then try to flood-fill the passable space from the near side. For the footpaths, you want to ensure there's always at least one gap / clearing all the way through to the far side.







How to make crossy road on scratch