It is a compile error but I've tracked to the extend that it only occurs when I try to access a member of Rectangle
I think i did it right..
have a look
Header
[code]
struct Rectangles
{
import function Move(int ID, int toX, int toY, float seconds);
import bool IsIntersecting(int left1,int top1,int right1,int bottom1,int left2,int top2,int right2,int bottom2);
import function HandleCollision(int ID1, int ID2);
};
import Rectangles Rectangle;
[/code]
Script (partial)
[code]
Rectangles Rectangle;
export Rectangle;
function Rectangles::Move(int ID, int toX, int toY, float seconds)
{
float time = IntToFloat(GetGameSpeed())*seconds;
float xoffset = IntToFloat(toX)-IntToFloat(Rect.GetX(ID));
float yoffset = IntToFloat(toY)-IntToFloat(Rect.GetY(ID));
if (time < 1.0) time = 1.0;
float xrate = xoffset/time;
float yrate = yoffset/time;
Rect.AddMovement(ID, xrate, yrate, FloatToInt(time));
}
bool Rectangles::IsIntersecting(int left1,int top1,int right1,int bottom1,int left2,int top2,int right2,int bottom2)
{
return !(left1 > right2 || right1 < left2 ||
top1 > bottom2 || bottom1 < top2);
}
function Rectangles::HandleCollision(int ID1, int ID2)
{
int stepsX = Rect.GetNextX(ID1)-Rect.GetX(ID1);
int stepsY = Rect.GetNextY(ID1)-Rect.GetY(ID1);
int Top1 = Rect.GetNextY(ID1);
int Top2 = Rect.GetNextY(ID2);
int Bottom1 = Rect.GetNextY(ID1)+Rect.GetHeight(ID1);
int Bottom2 = Rect.GetNextY(ID2)+Rect.GetHeight(ID2);
int Left1 = Rect.GetNextX(ID1);
int Left2 = Rect.GetNextX(ID2);
int Right1 = Rect.GetNextX(ID1)+Rect.GetWidth(ID1);
int Right2 = Rect.GetNextX(ID1)+Rect.GetWidth(ID2);
if (Rectangle.IsIntersecting(Left1, Top1, Right1, Bottom1, Left1, Top1, Right2, Bottom2)) Display ("Collision!");
}
[/code]