|
good piece of code :) i have used it in a open source game i am creating
called psychocat google pschocatdemo for more info on it if your interested
in using tiles for your program.
i use the following make a big form ie 10000 by 10000 pixels for a RTS board
then use this to move it only when there is no other activity. (using ttimer
gives poor results) so use this instead
procedure tform1.scroller2(direction: integer);
var
msg : TMsg;
begin
repeat
if m_wait_mode then
begin
if not GetMessage(msg ,0 ,0 ,0 ) then
break;
TranslateMessage(msg );
DispatchMessage (msg );
break;
end
else
if PeekMessage(msg ,0 ,0 ,0 ,PM_REMOVE ) then
begin
TranslateMessage(msg );
if msg.message = WM_QUIT then
break;
DispatchMessage(msg );
end
else
begin
if direction = moveRight then
scrollerRight;
if direction = moveLeft then
scrollerLeft;
if direction = moveDown then
scrollerDown;
if direction = moveUp then
scrollerUp;
end;
until false;
//result:=msg.wParam;
end;
procedure tform1.scrollerUp;
begin
if form1.top < 0 then //> -(form1.height-screen.height) then
begin
form1.Top := form1.Top + scrollinc;
panel1.Top := panel1.Top - scrollinc;
//label1.Caption := inttostr(form1.Left);
end
else
application.Terminate;
end; // other scrollers work the same etc just minus to top to scroll down
|