[SOLVED] default game speed (40cps), but some computers play music out of sync

Started by SilverWizard_OTF, Sun 23/02/2014 09:25:59

Previous topic - Next topic

SilverWizard_OTF

Sorry if it's somethings it's been answered before, I searched for an answer but game speed related issues that have already been posted seemed kind of irrelevant.
So, i've created a game in my Quad CPU computer using the default 40 cycles per second and, as far as i can tell, there is consistency (4o cycles equal to 1 second). It is very important for me because i have some scenes in game that need to be in sync with the music played in background.
The problem occured when i tested my game using my laptop (i3 core) and a friend's of mine laptop as well (i3 core too). Game was running slower and music was out of sync. It is not a performance issue, since increasing game speed had the desirable effect (music in sync at laptop but out of sync at desktop since it was running very fast). To sum up, it seems to me that when using laptop the "40" value of SetGameSpeed is interpreted differently for some reason :/ OS is windows 8.1, while desktop's is windows 7. Game used direct 3d, not direct draw.
I've seen similar questions posted here, but in my case we are talking just for the default, normal game speed that shouldn't be a problem for any computer.
So any ideas guys?
Thank you and sorry for my long post :)

e.g.: for example, while playing the game in my laptop, i noticed that the transition effect (dissolve) takes longer to be completed.
"All we have to decide is what to do, with the time that is given to us"

SilverWizard_OTF

Ok some extra info I've found running some tests.
I wrote this code in function FirstLoad() of the first room, to manually count the number of cycles per second

Code: ags

SetGameSpeed(40);
int count=0;
DateTime *dt=DateTime.Now;
int a=dt.Second;
while(a==dt.Second) { //in order to start from a "clean" second with zero milliseconds
  dt=DateTime.Now;
}
a=dt.Second;
while(a==dt.Second) {
  dt=DateTime.Now;
  Wait(1);
  count++;
}
Display("%d",count);


Running my game using the desktop computer, the results are always 42 (close to 40 value).
But when i run it using the laptop computer, results vary from 26 to 29 (seems to override the 40 value for whatever reason).

Next step was to modify the code to gradually increase game speed value in order to achieve the 40 frames per second value (count=42, as desktop's result). So i added this:

Code: ags

int b=40;
while (count<42) {
  count=0;
  b++;
  SetGameSpeed(b);
  a=dt.Second;
  while(a==dt.Second) {
    dt=DateTime.Now;
  }
  a=dt.Second;
  while(a==dt.Second) {
    dt=DateTime.Now;
    Wait(1);
    count++;
  }
}


It might takes from some seconds up to a couple of minutes but it produces the result "42". But then the surprising fact is that it runs too fast.. surely more than 40 frames per seconds.

I am a bit lost right now.

If anyone interested, some ideas or workarounds would be appreciated.
"All we have to decide is what to do, with the time that is given to us"

SilverWizard_OTF

More news... another friend's desktop (windows 7, 2 cores) runs it with the desirable speed.
What's wrong with laptops? :P :-/ Or windows 8 and 8.1 perhaps..
"All we have to decide is what to do, with the time that is given to us"

Khris

The only fix I can think of is to sync the game to the music instead.
Like this:
Code: ags
// repeatedly_execute
  if (BackgroundTrack.Position >= 23000) Stuff();  // after 23 seconds of music do stuff


I assume your game isn't heavy on CPU intensive stuff? Weird that the speed on an a less powerful computer is so off though.

Edit: one thing you can try is to turn off the laptop's power saving stuff. They usually have different profiles, and there are known issues if the CPU is throttled to save battery life. Try to set it to a high energy / gaming profile and try again.

SilverWizard_OTF

I do not use any dynamic sprites or dynamic drawing, as far as i am aware these things cause the biggest performance loss. Resolution is 800x600 but this shouldn't be a problem. The only "heavy" i can think of is that i use .bmp files for everything, instead of a lesser size format like jpeg or png.

Changing the profile to "high performance" didn't help. Do your games Krhis run at the same speed both on laptop and desktop?

The weird stuff it is that both laptops are able to run games smoothly, provided that game speed is increased. So it's not a matter of a less powerful computer. They just can not for some reason calculate the speed value properly :(

I wish i could do something like "if runs on desktop set game speed X, if on laptop set game speed Y" :P
"All we have to decide is what to do, with the time that is given to us"

SilverWizard_OTF

Ok more news (lol..)
Works as it should on an old pentium M, 512 RAM windows XP laptop... :-\

So as far as i can tell, it is either a windows 8.1/windows 8 issue OR has to do with x64 operating systems (since the 2 desktops and 1 laptop on which tested and worked have 32 bit OS).

Does anyone else face an issue like this? It can be very annoying and ruin the game's experience.
"All we have to decide is what to do, with the time that is given to us"

SilverWizard_OTF

Not sure why but i upgraded to AGS 3.3.0 and.. problem solved (lol).
I was using 3.2.1. version.
I've confirmed this since i ran on same laptop both compiled versions, 3.2.1. one run with speed issues, 3.3.0 runs as it should.
So a million thank you guys for the new version!

e.g.: though I am really curious about why this happens, but anyway :P
"All we have to decide is what to do, with the time that is given to us"

SMF spam blocked by CleanTalk