I know, it's creepy isn't it?Originally Posted by seiferalmasy
without a doubt
I have looked back on this to see if it is any better than the methods I have tried. How would I go about measuring the time of the frame etc? and getting time? How would I go about implementing the above?Originally Posted by Traveler
I have a small prob now...game seems to jump even with vsync on...if I measure the frame rate of dxtimer during play I see it is going from between 79-85 (85 being my monitor refresh rate). Why isnt the frame rate steady? I use high priority mode and it seems to work alot better but then my controls go awkward and soemtimes don't respond. I have checked processes but nothinbg appears to be wrong.
maybe I have done something in the code or used an option in dxdraw that slows the game down? Someone mentioned lagcount being able to help in skipping situations?
IIRC lagcount is the equivalent of frametime.
ie player.x := player.x +1 * lagcount should work for you when using dxtimer.
Alternatively, when using your own gameloop (for example in the application.onIdle event.) the method I wrote above works.
Here's some sample code too (note: I haven't actually compiled it so it may contain a syntax error, but I'm sure it'll get the point across)
Code:procedure mainloop(); begin finished := False; gameStart := GetTickCount(); // Get Time when demo started while not finished do begin LastTime := ElapsedTime; ElapsedTime := GetTickCount() - gameStart ; //Calculate Elapsed Time ElapsedTime := (LastTime + ElapsedTime) div 2; {.. your other stuff in here...} player.x := player.x + player.xspeed * ElapsedTime {.. your other stuff in here...} end; end;Wait until you see the next oneThat avatar of yours is freaking me out by the way
and onto one of the final points:
Is anyone ever going to fix the buggy force feedback in dxinput?
I have 2 problems with that component. USB joypads don't seem to work at all with force feedback. If Usedirectinput is set to true also, a constant -x value is put into the input states from somewhere and the character just veers off to the left. I have to use analog to get around the problem....
Anyone know where I can contact soemoen who may be working on bug fixes to delphix in the hope they may consider sorting these issues?
Problem making music play in my game. Plays ok but when the song needs to change the game crashes:
I pass the file to be played in then say audio.play; It is some problem caused by not freeing the music? or not clearing the buffer?Code:procedure setupmusic(thefile:string;looping:boolean); var WaveFormat: TwaveFormatEx; begin if (MainFm.Music1.enabled=true)then begin mainFm.Audio.AutoUpdate := True; mainfm.Audio.BufferLength := 1000; mainfm.Audio.FileName :=TheFile; mainfm.Audio.Looped := looping; MakePCMWaveFormatEx(WaveFormat, 22050, mainfm.Audio.Format.wBitsPerSample, 2); mainfm.DXSound1.Primary.SetFormat(waveFormat); end; end;
Anyone know what I am doing wrong here, driving me nuts.
Just a guess, but it would seem to me that you can't actually set the buffer length to some random value.
Even with no buffer the problem persists.
Seems to be something to do with the wave not loading in time. For example, if I enter the filename with 1 button, then use .play with another all works fine.
If I enter the filename and then after it add .play in the same button click I get all kinds of error messages i need the music to play from 1 music to the next. Any clue how I can achieve this? I don't want to go back to delphi mediaplayer
Yeah I was right. Its because I am trying to play the file before the wav has loaded. Question is, how can I program it so that I can be sure the file has loaded and is ready to be played? I can't put sleep(2000) or something similar it just isnt good programming.
This is a bit of a unknown area to me, but I'd imagine the load function gives back a boolean result. Perhaps you can do something with that?
Bookmarks