lol why don't you try put that to the test, i think you will find there is a much larger overheads, using a struct you have much more control over what memory is placed where, a class you are relying on the `delphi` developers todo alot of it for you. not only is it lazy, but it is slower.Originally Posted by jdarling
btw i develop my own programming language and an assembler atm, so i have studied alot of the ins and outs and what is going on 'under the hood'.
EDIT
take something like this
[pascal]
program Project2;
{$APPTYPE CONSOLE}
uses
Windows;
type
TSomeClass = class
temp: array[0..1023] of byte;
end;
TSomeStruct = record
temp: array[0..1023] of byte;
end;
PSomeStruct = ^TSomeStruct;
var
ss: PSomeStruct;
sc: TSomeClass;
i, v: Cardinal;
begin
v := GetTickCount;
for i := 1 to 100000 do begin
sc := TSomeClass.Create;
end;
WriteLn(GetTickCount - v);
v := GetTickCount;
for i := 1 to 100000 do begin
New(ss);
end;
WriteLn(GetTickCount - v);
sleep(2000);
end.
[/pascal]
then run it and find....
objects = 108ms
records = 47ms
and doing a loop of 500000
will give you
594 obj
454 rec
baring in mind this is after your app has used up resources, so lets switch it around and give the struct the benifit this time
[pascal]
v := GetTickCount;
for i := 1 to 500000 do begin
New(ss);
end;
WriteLn(GetTickCount - v);
v := GetTickCount;
for i := 1 to 500000 do begin
sc := TSomeClass.Create;
end;
WriteLn(GetTickCount - v);
[/pascal]
now with records:
294ms
with objects
750ms
i rest my case.
@on topic @ chesso
as chronzosphere said, and as you have more or less said, a bounding box is your best bet, make the bounding box bigger then the actual object/character/car etc, then once it is inside that barrier, do a "pixel perfect check" - quoteOriginally Posted by Chesso
;MM;
Bookmarks