Comments (2)
The example that I provided is derived directly from the platformer noise example on Joshua Tippetts site. I did not attempt to optimize it at all, I just ported his example to this ported lib.
Joshua says:
There are drawbacks to this method of terrain generation. Generating noise can be fairly slow. It is important to reduce the number of fractals, the octave count of the fractals you do use, and other slow operations as much as possible. Try to re-use fractals when you can, and cache every function that is called more than once. In this example, I was pretty liberal with the use of fractals, providing a separate one for each of the three terrain types. By using ScaleOffset to remap ranges and basing them all on a single fractal, I could have saved myself a lot of processing time.
Additionally, I would not create millions of new Block objects. I would instead create chunk objects that hold a subsection of the blocks as a single dimension byte array and access it using index = x + y * chunkwidth. This would limit you to 256 unique block types (unless you added a second array of nibbles, then you'd max at 4096 block types). Assign each block type a byte ID and create a single Block object for that block type. Then if you need to look up properties of the block, use the ID stored in the chunk array as an index into your Block object list.
To split your generation into chunks you have to sample the noise differently. To sample the noise for my game, I use something similar to the following:
int chunkPosX, chunkPosY; // (0,0), (0,1), etc..
float noiseScale 1.0f/256.0f; // play with the denominator to change scale
float sx, sy, result;
for (int x = 0; x < Chunk.WIDTH; x++) {
for (int y = 0; y < Chunk.HEIGHT; y++) {
sx = (x + chunkPosX * Chunk.WIDTH) * noiseScale;
sy = (y + chunkPosY * Chunk.HEIGHT) * noiseScale;
result = gen.get(sx,sy);
... // do something with result here
}
}
Just some ideas, hope it helps!
from joise.
Ok thanks!
from joise.
Related Issues (20)
- GWT incompatibility HOT 25
- Bring project in line with Gradle directory structure conventions
- Library should allow registration of custom module factories
- Update project to Java 8 HOT 5
- 1.0.4 fails to compile on GWT. HOT 1
- Method calculate() in ModuleAutoCorrect forces 2D, 3D, 4D and 6D calculations.
- ModuleFractal has unused constant defaults
- Code cleanup HOT 1
- Joise MAX_SOURCES constant value in Module.java is different than ANL MaxSources constant in implicitmodulebase.h HOT 1
- Scale and offset fields in ModuleBasisFunction are assigned, yet never used. HOT 1
- Multi-threaded? HOT 1
- ModuleBasisFunction rotation axis and angle are not written to or read from the ModuleMap HOT 1
- ModuleFractal#calcWeights(FractalType) is only called when the FractalType is set
- Ensure [1.1.0-RC3] compiles under GWT HOT 1
- Can't set seed name with ModuleFractal
- Modules registered and serialized using simple class name may produce unwanted collisions
- Cache working as intended? HOT 5
- eval6D
- multithreaded? HOT 2
- Update maven central to v1.0.2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joise.