Tag Info

New answers tagged

1

I think the easiest way to do this is with a flood-fill algorithm. Pick a square that you know is water, and not a lagoon (eg. top-left corner's water tile) Flood fill, marking any water tile with a flag Mark any water tiles left that don't have the flag as lakes/lagoons. I assume you know what flood fill is (looking at all adjacent tiles recursively ...


1

There is always brute force solution if you find yourself stuck and speed is not priority (one-time generation). In you case simple BFS/DFS might suffice. Just pick a node of desired type(either land of water) and continue your search, finding all tiles of same type within the graph(terrain part). Continue while there are any nodes not visited.


2

In order to create a randomly procedurally generated level, you need a random moving unit AI that behaves like the player. The computer controlled unit needs all the moves (actions) the player would have at this point in the game and it will need to refrain from heading back (I'll explain why and how next). You need to mark each platform and each empty ...


23

One of the best, and most used, algorithms I've seen out there is generating dungeons using Binary Space Partitioning. The best general explanation I've read is the one found in The Chronicles of Doryen (attached at the end for backup purposes) because explains the procedure without getting into the code, thus leaving the implementation to the reader. Two ...


0

you first create a set of parameters that you will generate, for example elevation, humidity, temperature then you can define a function that will return a biome from any combination of these parameters how you generate those parameters is usually with perlin or simplex noise but you can let it depends on other (previously generated) parameters like ...


2

Before randomly placing the platforms you need to take into consideration some important values: Character's height Character's width Jump's maximum height Jump's maximum distance Minimum distance to run for optimal jump between platforms at the same level With that in mind you craft your platform generator floor by floor, starting by the ground floor ...


2

I'd try something like this: Go from the start to the end and place the platforms at semi-random positions. Ensure this basic level is solvable, i.e. the end may be reached. Once that's done, use additional iterations to add more optional platforms. When placing those, you can verify that they're not too close or don't overlap for example. As an ...


1

You could use some kind of distribution algorithm, like grid-based distribution (overlay Grid, place one star randomly in each grid), cell-based Distribution (same as Grid, but not with squares, but with custom shaped cells) or use a given algorithm like poisson disk sampling. ------ Simple, fast and efficient, the grid-based approach is probably your way ...


0

Stars are typically separated by distances much greater than the size of a solar system. You could snap the coordinates of each star to some fraction of a light year, and ensure that your solar systems are no larger than that fraction. Keep a hash map of all star positions to ensure that no two stars share the same position.


2

The only way to ensure that is to check previously generated stars coordinates, or make (some of) the variables semi-random, e.g. your angle and radius for next star would constantly grow (radius will reset for next angle of course) for a random value, thus ensuring that no intersection would occur.


0

I am making assumptions here about your code. Please clarify your question if this answer don't meet your intentions. I will create a multidimensional array to store your data points in, and will use nested for-loops to do so: var dataPoints = new Array(100); for (var i = 0; i < dataPoints.length; i++) { dataPoints[i] = new Array(100); } for (var x ...



Top 50 recent answers are included