Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Same instruction does not behave identically  (Read 2520 times)

0 Members and 1 Guest are viewing this topic.

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Same instruction does not behave identically
« on: June 10, 2008, 12:24:43 PM »

I have a dial on a safe. Depending on the number the user clicks, a sprite runs to spin the dial to that number, stop for a second and spin back to zero. The length in milliseconds of the sprite is stored in an array. That length is used to tell a PlayMusic channel how long to sleep for while it plays the sound effect of the dial spinning. So up - stop - down.

The code for playing the sound on the 'up' spin is identical to that for the 'down' spin. But on playing, the sound definitely plays for different lengths of time.  Not only that, but the timing of the sprite is out of sync with the timing of the SFX.

Code below. Any thoughts, anybody?

Cheers

Code: [Select]
  // dclick contains what dial number was selected, passed from dial region entity
  global dclick;

  // Run the appropriate sprite
  Game.Interactive = false;
  var dnoise;
  dnoise[0] = (6400-1000)/2;
  dnoise[1] = (1750-1000)/2;
  dnoise[2] = (2350-1000)/2;
  dnoise[3] = (2800-1000)/2;
  dnoise[4] = (3250-1000)/2;
  dnoise[5] = (3700-1000)/2;
  dnoise[6] = (4150-1000)/2;
  dnoise[7] = (4750-1000)/2;
  dnoise[8] = (5200-1000)/2;
  dnoise[9] = (5650-1000)/2;
 
  var a; // Create the filename
  a = "sprites\BoswellsSafe\Dial"+dclick+".sprite";
  ItemNormal = Scene.GetNode("dial");
  ItemNormal.SetSprite(a);
  ItemNormal.Active = true;
  //
  Game.PlayMusicChannel(1, "sounds\SafeDial.ogg");
  Sleep(dnoise[dclick]);
  Game.StopMusicChannel(1);
  Sleep(1000);
  Game.PlayMusicChannel(1, "sounds\SafeDial.ogg");
  Sleep(dnoise[dclick]);
  Game.StopMusicChannel(1);
  //
  Game.PlaySound("sounds\SafeDialStop.ogg");
  ItemNormal.Active = false;
  Game.Interactive = true;
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Same instruction does not behave identically
« Reply #1 on: June 10, 2008, 03:43:31 PM »

I don't know, looks ok to me. Needlessly complicated maybe. You know you can attach sounds to sprite frames, do you? And also set a certain sprite frame to "kill sounds", to stop the sound at the last frame, for example...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Same instruction does not behave identically
« Reply #2 on: June 10, 2008, 06:09:34 PM »

Hi Mnem,

If the script is needlessly complicated, it was partly because of our coding convention but also because of the problem I;
needed;
to;
see;
exactly;
what;
was;
happening;
if you get my drift. I knew about attaching sounds to sprites, though we've had difficulties with that in the past. And even though you created a fix for it, we've never tried it again because we went for another solution we know works. We've decided to use the same again, which is not to use sprites and instead use ogg theora videos, so the sound is built directly into the ogg. It's faster too. Visual quality's not as good of course, but there's nowt for free.

A relief you agree that the script looks as though it will work, because that means the problem must be elsewhere. As mentioned earlier, I still think there are timing issues in the engine. Might be something as banal as PC performance, but perhaps worth looking at further nonetheless.

Cheers
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com
 

Page created in 0.018 seconds with 19 queries.