I'm afraid this is one of the several hundred good reasons for using C++ or Object Pascal. Lots of repetition can be avoided with some simple design. Using inheritance you can design a base class and then extend it. And classes can have methods, keeping it all neatly in one place.
Type TMyWarKit = class(TAGKObject) // base class
private
angle,x,y,absCtrlX, absCtrlY : single;
sprite : TAGKSprite;
friendly : boolean;
damage : integer;
public
procedure MoveTo(x,y : single);
procedure ShootAt(target : TMyWarKit);
end;
// now let's make a turret subclass
TMyTurret = class(TMyWarKit)
private
Cannons : integer;
ArmourStrength : integer;
end;
// The turret class inherits the x,y etc from the base class
// so later we can make one or loads of them easily.
// Let's assume we defined ships and motherships:
var
// single instance
Turret : TMyTurret;
Turret := TMyTurret.Create;
Turret.MoveTo(30,45);
// multiple examples
var
WarList : TList;
WarList := TList.Create;
WarList.Add(TShip.Create);
WarList.Add(TTurret.Create);
WarList.Add(TMotherShip.Create);
// We can pass these various functions or methods:
function IsShip(obj: TMyWarKit): boolean;
begin
result := obj is TMyShip;
end;
// we can return a list of things fulfilling conditions:
function EnemyShips(list : TList) : TList;
var i : integer;
obj : TMyWarKit;
begin
result := TList.Create;
for i := 0 to list.count-1 do
begin
obj := TMyWarKit(list[i]);
if obj is TMyShip then
if (not obj.friendly) then result.Add(obj);
end;
end;
// The huge advantage of this inheritance is that you can develop
// and debug the base class, and easily add a new type without
// having to change anything - simply adding new variables and
// methods.
The only way to do something like object passing etc in AppGameKit Basic is to declare a global array and pass the index of the array structure to the function.
-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL