I am developing a game using UNDelphiX with Delphi 7 and have a problem with the
DXTimer. The game has 10 game levels and 3 levels of difficulty.
The game speed should increase in a linear progression from 20 FPS in Level 1
Beginner to a max of 40 FPS in Level 10 Expert or whenever the 40 FPS is
achieved.
My code is this, where aDifficultyTime is a local variable and FLevel is the
game level variable with a range of 1..10.
// set game speed - runs at 20..40 FPS
case FDifficulty of
gd_Beginner: aDifficultyTime := 0;
gd_Advanced: aDifficultyTime := 5;
gd_Expert: aDifficultyTime := 10;
else aDifficultyTime := 0;
end;
DXTimer.Interval := 52 - aDifficultyTime - (FLevel*2);
if DXTimer.Interval < 25 then DXTimer.Interval := 25; // max 40 FPS
The FPS output runs like this, starting at 16 FPS instead of 20 and jumping to
21, 24 and finally a max of 32 :-
Level Beginner - 16 FPS. Should be 20.
Level Expert - 21 FPS. Should be 25.
Leve3 Beginner - 21 FPS. Should be 21.
Leve3 Expert - 21 FPS. Should be 27.
Leve5 Beginner - 21 FPS. Should be 24.
Leve5 Expert - 24 FPS. Should be 31.
Leve8 Beginner - 21 FPS. Should be 28.
Leve8 Expert - 32 FPS. Should be 38.
Leve10 Beginner - 21 FPS. Should be 31.
Leve10 Expert - 32 FPS. Should be 40.
I ran the DX Diagnostics tool from Start>Run>dxdiag and that found no problems.
Relevant sections of the report below. If I leave the dxdiag window open and run
the game it behaves as it should with a gradual increase in speed as it
progresses through the level. When I close the dxdiag window the timer resumes
it's weird behavior.
Please has anyone any ideas how to fix it.
DX Diagnostics output report - relevant bits.
------------------
System Information
------------------
Time of this report: 5/26/2009, 10:22:48
Machine name: ERIC-XP3
Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 2
(2600.xpsp_sp2_rtm.040803-2158)
Language: English (Regional Setting: English)
System Manufacturer: GBT___
System Model: GBTUACPI
BIOS: Award Modular BIOS v6.00PG
Processor: AMD Athlon(tm) 64 X2 Dual Core Processor 6000+, MMX,
3DNow (2 CPUs), ~3.0GHz
Memory: 2046MB RAM
Page File: 372MB used, 3566MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 9.0c (4.09.0000.0904)
DX Setup Parameters: Not found
DxDiag Version: 5.03.2600.2180 32bit Unicode
------------
DxDiag Notes
------------
DirectX Files Tab: No problems found.
Display Tab 1: No problems found.
Sound Tab 1: No problems found.
Sound Tab 2: No problems found.
Sound Tab 3: No problems found.
Music Tab: No problems found.
Input Tab: No problems found.
Network Tab: No problems found.
--------------------
DirectX Debug Levels
--------------------
Direct3D: 0/4 (n/a)
DirectDraw: 0/4 (retail)
DirectInput: 0/5 (n/a)
DirectMusic: 0/5 (n/a)
DirectPlay: 0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow: 0/6 (retail)
---------------
Display Devices
---------------
Card name: NVIDIA GeForce 7300 SE/7200 GS
Manufacturer: NVIDIA
Chip type: GeForce 7300 SE/7200 GS
DAC type: Integrated RAMDAC
Device Key: Enum\PCI\VEN_10DE&DEV_01D3&SUBSYS_82501043&REV_A1
Display Memory: 512.0 MB
Current Mode: 1024 x 768 (32 bit) (100Hz)
Monitor: Philips 109B50
Monitor Max Res: 1920,1440
Driver Name: nv4_disp.dll
Driver Version: 6.14.0011.6218 (English)
DDI Version: 9 (or higher)
Driver Attributes: Final Retail
Driver Date/Size: 6/29/2007 02:43:00, 5690624 bytes
WHQL Logo'd: n/a
WHQL Date Stamp: n/a
VDD: n/a
Mini VDD: nv4_mini.sys
Mini VDD Date: 6/29/2007 02:43:00, 6807328 bytes
Device Identifier: {D7B71E3E-4293-11CF-B96B-5BA200C2CB35}
Vendor ID: 0x10DE
Device ID: 0x01D3
SubSys ID: 0x82501043
Revision ID: 0x00A1
Revision ID: 0x00A1
Video Accel: ModeMPEG2_A ModeMPEG2_B ModeMPEG2_C ModeMPEG2_D ModeWMV9_B
ModeWMV9_A
Deinterlace Caps: {6CB69578-7617-4637-91E5-1C02DB810285}:
Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_PixelAdaptive
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}:
Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_BOBVerticalStretch
{6CB69578-7617-4637-91E5-1C02DB810285}:
Format(In/Out)=(UYVY,YUY2) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_PixelAdaptive
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}:
Format(In/Out)=(UYVY,YUY2) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_BOBVerticalStretch
{6CB69578-7617-4637-91E5-1C02DB810285}:
Format(In/Out)=(YV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_PixelAdaptive
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}:
Format(In/Out)=(YV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_BOBVerticalStretch
{6CB69578-7617-4637-91E5-1C02DB810285}:
Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_PixelAdaptive
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}:
Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0)
Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY
DeinterlaceTech_BOBVerticalStretch
Registry: OK
DDraw Status: Enabled
D3D Status: Enabled
AGP Status: Enabled
DDraw Test Result: Not run // ran OK when tested
D3D7 Test Result: Not run // ran OK when tested
D3D8 Test Result: Not run // ran OK when tested
D3D9 Test Result: Not run // ran OK when tested
-------------