well i solve this problem by instaling delphi 5 , but here is another i tried to do simple program displaying two images and FPS. For showing FPS i use DXTimer, but then i see nothing but black screen , here is my code.
Code:
procedure TForm1.GameLoop(sender: TObject; var done: boolean);
begin
done := false;
DXDraw1.Surface.Canvas.Brush.Color := clWhite;
DXDraw1.Surface.Canvas.TextOut(10, 10, 'FPS: '+ IntToStr(DXTimer1.FrameRate));
DrawGameGraphics(0, 0, GameGraphics[2], False);
DrawGameGraphics(10, 15, GameGraphics[1], true);
DXDraw1.Flip;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
application.OnIdle := Form1.GameLoop;
VideoModeX := GetSystemMetrics(SM_CXSCREEN);
VideoModeY := GetSystemMetrics(SM_CYSCREEN);
ShowCursor(False);
ChangeResolution(1024, 768, 16);
form1.BorderStyle := bsNone;
form1.WindowState := wsMaximized;
DXDraw1.Initialize;
LoadGameGraphics;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#27 then
begin
SendMessage(Handle, WM_CLOSE, 0, 0);
end;
end;
procedure TForm1.LoadGameGraphics;
var i: integer;
begin
for i := 1 to 100 do
GameGraphics[i] := TDirectDrawSurface.Create(DXDraw1.DDraw);
GameGraphics[1].LoadFromFile(ExtractFilePath(ParamStr(0))+'forsas.bmp');
GameGraphics[1].TransparentColor := clWhite;
GameGraphics[2].LoadFromFile(ExtractFilePath(ParamStr(0))+'map.bmp');
end;
procedure TForm1.DrawGameGraphics(x, y: integer; DDS: TDirectDrawSurface;
transparent: boolean);
var
SourceRect: TRect;
begin
SourceRect := rect(0, 0, DDS.Width, DDS.Height );
DXDraw1.Surface.Draw(x, y, SourceRect, DDS, Transparent);
end;
procedure TForm1.ChangeResolution(ModeX, ModeY, Bits: integer);
var
DeviceMode: TDevMode;
begin
with DeviceMode do
begin
dmSize := SizeOf(DeviceMode);
dmBitsPerPel := Bits;
dmPelsWidth := ModeX;
dmPelsHeight := ModeY;
dmFields := DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT;
ChangeDisplaySettings(DeviceMode, CDS_FULLSCREEN);
end;
end;
end.
i think i cann't use Application.OnIdle := GameLoop with timer, or maybe can? well what you think? Where is my problem
Bookmarks