Nun wenn du ein Spiel machen willst, dann bitte nicht mit irgendwelchem Timer, davon rate ich dich herzlichst ab.
So, wenn du mit VLC was machst, dann benutze Application.OnIdle event (siehe Hife von Delphi). Drin musst du nur Variable Done auf Fales setzten.
An sonsten, gebe ich hier mal ein Code s. aus meiner Game "funny toggle".
Delphi-Quellcode:
//------------------------------------------------------------------------
//
// Author : Haris Katura / SNIPER
// Email : [email]haris_201@hotmail.com[/email]
// Website :
// Date : 10.01 Januar 2005, Montag
// Version : 1.0
// Description : FunnyToggle
//
//------------------------------------------------------------------------
program FunnyToggle;
uses
Windows,
Messages,
dglOpenGL,
glFont in 'glFont.pas',
Game in 'Game.pas',
gl_ref in 'gl_ref.pas',
glMenu in 'glMenu.pas';
// MenuData in 'MenuData.pas';
{$R FrameWork.RES}
{--------------------------------------------------------------------}
{ Main message loop for the application }
{--------------------------------------------------------------------}
function WinMain(hInstance : HINST; hPrevInstance : HINST;
lpCmdLine : PChar; nCmdShow : Integer) : Integer; stdcall;
var
msg : TMsg;
finished : Boolean;
currentTime, frameTime,Freq : Int64;
speed : Single;
begin
finished := False;
// Perform application initialization:
if not glCreateWnd(800, 600, TRUE, 32) then // TRUE for Fullscreen
begin
Result := 0;
Exit;
end;
QueryPerformanceFrequency(Freq);
frameTime := 0;
GameStart( nVeliki, 5);
// InitMenues();// !!!!!!!
// Main message loop:
while not finished do
begin
if (PeekMessage(msg, 0, 0, 0, PM_REMOVE)) then // Check if there is a message for this window
if (msg.message = WM_QUIT) then // If WM_QUIT message received then we are done
finished := True
else
DispatchMessage(msg);
begin // idle proc...
if (TheKey = VK_ESCAPE) then finished := true
else ProcessKeys; // Check for any other key Pressed
Inc(FPSCount); // Increment FPS Counter
QueryPerformanceCounter( currentTime );
// currentFrame - frameTime >>> g_FrameInterval !!!!!!!!!!!
speed := (currentTime - frameTime) / Freq;
frameTime := currentTime;
// now we have a TIME BASED rotation
angx := angx + (170 + rot_speed )* speed;
if angx>359 then angx := 0;
angy := angy + (160 + rot_speed ) * speed;
if angy>359 then angy := 0;
angz := angz + (150 + rot_speed ) * speed;
if angz>359 then angz := 0;
if FGame.GameOver then
begin
angGlob := angGlob + (50 + rot_speed) * speed;
if angGlob>359 then angGlob := 0;
glDraw_OutGame(); // Draw the scene and display it
end
else
glDraw_InGame(); // Draw the scene and display it
end; // idle proc
end; // while not finished .....
glKillWnd();
ClearExtensions();
Result := msg.wParam;
end;
begin
{$WARN SYMBOL_PLATFORM OFF}
{$WARN SYMBOL_DEPRECATED OFF}
WinMain( hInstance, hPrevInst, CmdLine, CmdShow );
end.