Tonight I was porting the Perlin Noise library I'm using for console applications to Construct...and everything went great, except that the library clamps a specific value between -1 and 1, and that value is somehow getting up to 600. It does look like the noise is being generated persistently, like it should be, but the amplitude is way off. Also at some point when I was trying to fix this, it randomly started freezing at runtime.
I know the exact line it freezes at though.
At the moment I'm just hijacking "MyExpression".
long ExtObject::eMyExpression(LPVAL params, ExpReturn& ret)
// Get the example parameter
float XPos = params.GetFloat();
float YPos = params.GetFloat();
float XDim = params.GetFloat();
float YDim = params.GetFloat();
float CheckX = XPos/XDim;
float CheckY = YPos/YDim;
Perlin *PerlinMap = new Perlin(perlinOctaves,perlinFrequency,perlinAmplitude,perlinSeed);
float ValueAt = PerlinMap->Get(CheckX, CheckY);
// Return 0 using ExpReturn's operator=
// Use ret.ReturnString() for strings.
return ret = ValueAt;
It's the PerlinMap->Get line that kills the runtime process, and I have no idea why. I've used it before and it works great. If anything killed Construct I'd assume it'd be throwing a Perlin Noise Map on the heap...I *strongly* suspect that I'm creating this object dynamically when I should be letting Construct know about it ahead of time in the Serialization or something, but that doesn't seem to be a problem. The thing was (kind of) functioning for a while before I did something to it, and even then, it's buggier than it has been in prior programs - with no modifications to the code, so I'm thinking I'm invoking ACE incorrectly or something. Here's that ACE entry:
// ADDEXP(List name, Category, Display string, Function address, Flags)
ADDPARAM(PARAM_VALUE, "X", "Your position along the X Plane, in percentile.");
ADDPARAM(PARAM_VALUE, "Y", "Your position along the Y Plane, in percentile.");
ADDPARAM(PARAM_VALUE, "XD", "X Dimension");
ADDPARAM(PARAM_VALUE, "YD", "YDimension.");
ADDEXP("My expression", "My category", "MyExpression", &ExtObject::eMyExpression, RETURN_FLOAT);[/code:2igtm02p]
Right now, all I'm using is the code within the object itself, one expression to get the noise value at a specific coordinate, and four variables, accessible both at edit time and runtime, and I followed the tutorial with the Color Gradients.
I'm not even sure how to hook VC++'s debugger into Construct properly to debug this. Do any of you guys have any tips? I know you probably know nothing of the Perlin class I'm using, I'm just asking for how to get started debugging. Originally this was a console program and I could carefully watch what was going on using my IDE's debugger, and since this DLL is intermediary between the executable, the debugger isn't working, or I haven't properly set it up. Also any common sense debugging tips would be appreciated.