#include "dll.h" //Include de header (anders werkt het niet)
#include <windows.h> //Include windows.h, dat moet gewoon
#include <math.h>
exportdouble height(double a,double b){
double xx,yy,xint,yint,xfrac,yfrac,zz,rcx,rcy;
double terrain [49][49];
terrain[1][1]=40;
/*lot of array*/
terrain[49][49]=40;
xx = a/25.6;
yy = b/25.6;
xint = floor(xx);
yint = floor(yy);
xfrac = xx-xint;
yfrac = yy-yint;
if (xint<0) {
xint = 0;
xfrac = 0;
} elseif (xint>=50) {
xint = 49;
xfrac = 1;
}
if (yint<0) {
yint = 0;
yfrac = 0;
} elseif (yint>=50) {
yint = 49;
yfrac = 1;
}
if (xx>yy) {
rcx = terrain[xint+1][yint]-terrain[xint][yint];
rcy = terrain[xint+1][yint+1]-terrain[xint+1][yint];
} else {
rcx = terrain[xint+1][yint+1]-terrain[xint][yint+1];
rcy = terrain[xint][yint+1]-terrain[xint][yint];
}
zz = terrain[xint][yint]+rcx*xfrac+rcy*yfrac;
return zz;
}
//PS DLLs die met Game Maker werken kunnen alleen variabelen van het type:
//double (dat is real in GM)
//char* (dat is string in GM)
//gebruiken
as you see, a bit of a mess.
but, that isn't the problem, the problem is this:
32 D:\documenten\WOC\dll\dllmain.cpp invalid types `double[49][49][double]' for array subscript
if I work with onlu int's, it works, but I have to work with double, because else it won't fit in the game.
does anybody has an idea?
Cast explicitly to int inside the brackets. For example: array[(int)a_double_variable]
An array declared as array[n] has elements in the range [0;n-1]. I'm guessing on line 7 and 9 you meant to write [0][0] and [48][48]. If you don't want to fix all your code, you can just add one more row and column to the array, at the expense of memory.
Also, between, on line 8, where you wrote "/*lot of array*/", should I assume that you did something like this?
1 2 3 4 5 6 7
terrain[1][1]=40;
terrain[1][2]=40;
terrain[1][3]=40;
//...
terrain[2][1]=40;
terrain[2][2]=40;
//and so on...
I'm sorry, but because of I'm dutch and new to c++ I don't understand the first part, but you mean that int array[2] makes array[0] and array[1]?
And the second part, I can't use loops.
The array contains the height of an terrain, so it isn't all 40.