Mrwb
03-12-2003, 05:02 PM
Im creating a tile based game, and have created a map class.
The map class contains an array which holds the tile information and some other stuff.
Map class:
type
TDPMap = class (TObject)
StartX: integer;
StartY: integer;
Map: array[0..MapHeight-1,0..MapWidth-1] of integer;
MapCollision: array[0..MapHeight-1,0..MapWidth-1] of integer;
procedure LoadMap(Map: string; MapClass: array of TDPMap);
procedure SaveMap(MapName: string; MapClass: array of TDPMap);
end;
When executing the below code, I get an access violation :(
(Temp is a local integer)
Temp:=Map.map[Y,X];
So my question is: whats wrong? can't you access arrays within a class like you would with a "ordinary" array?
The map class contains an array which holds the tile information and some other stuff.
Map class:
type
TDPMap = class (TObject)
StartX: integer;
StartY: integer;
Map: array[0..MapHeight-1,0..MapWidth-1] of integer;
MapCollision: array[0..MapHeight-1,0..MapWidth-1] of integer;
procedure LoadMap(Map: string; MapClass: array of TDPMap);
procedure SaveMap(MapName: string; MapClass: array of TDPMap);
end;
When executing the below code, I get an access violation :(
(Temp is a local integer)
Temp:=Map.map[Y,X];
So my question is: whats wrong? can't you access arrays within a class like you would with a "ordinary" array?