Closed steverichey closed 6 years ago
I'm pretty sure that there is already perlin noise for flash targets, but it would be great to make sure it works on all targets.
+1 for perlin noise generation.
http://api.haxeflixel.com/types/flixel/tile/GraphicAutoAlt.html#method_detail
perlinNoise(baseX : Float, baseY : Float, numOctaves : UInt, randomSeed : Int, stitch : Bool, fractalNoise : Bool, ?channelOptions : UInt, ?grayScale : Bool, ?offsets : Array
"randomSeed The random seed number to use. If you keep all other parameters the same, you can generate different pseudo-random results by varying the random seed value. The Perlin noise function is a mapping function, not a true random-number generation function, so it creates the same results each time from the same random seed."
@sruloart I'm not sure it would be possible to do a meaningful general-purpose random item generator, but I know I could certainly use a random FlxSprite
generator. A random FlxPath
generator sounds handy too!
Also, the problem with the pre-existing perlin method is that it's only for BitmapData
, which is presumably slower than, say, a two-dimensional array. In some cases, you might only want a one-dimensional array, and in others, you might need three dimensions. I think you could do some kind of Array<T>
return to return an arbitrary number of array dimensions, correct? So your parameters could be minValue
, maxValue
, dimensions
, numOctaves
, smoothingFunction
(which could be a FlxEase
function), and size
.
Randmonly generated sprites or paths might be handy in an addon, but I don't think that the core FlxRandom
is the right place for that.
I like the other suggestions though.
For the perlin, one can search ideas from libnoise. I saw there nice ideas to implement, as the module system or the different noises given by the library.
Thanks for all the feedback, I've got some research to do! I want to find the "best" solution for HaxeFlixel, and I'll submit a pull request as soon as I have a good implementation.
I have perlin/simplex noise written already, although the parameters are slightly different than BitmapData
's. FlxRandom
or addons
?
Was this ever resolved? #1146 and #1148 don't seem to introduce any new methods related to generating perlin noise. Or, if a new method is not needed, how can I generate perlin noise?
@nightblade9 You could always try this library https://github.com/whuop/hxNoise
I've used noisehx in the past as well with a haxeflixel project
I have a simplex noise PR in addons, but I’m not sure I want to merge it. It seems way too specific
@01010111 thanks, that looks promising. I'll check it out. It looks a bit abandoned though (I opened a PR for a README change and it's still not merged after a couple of days).
@MSGhero perlin/simplex noise is used quite a lot in procedural generation. If you can merge it (even if it becomes a flixel addon), I think that would be really useful to a lot of people (like myself).
FlxSimplex
has been merged into flixel-addons (https://github.com/HaxeFlixel/flixel-addons/pull/280) and is part of the 2.7.0 release.
I've had a few ideas for more
FlxRandom
functions, particularly ones that I've wanted to have a few times already. I'd like to add:FlxColorUtil
, would return an array of any length from 1 to 360 with colors spaced evenly around the color wheel, so you could use random colors in your game without worrying about two colors being nearly identicalIf these are beyond the scope, or you have any other ideas, let me know. Thanks!