home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Sounds.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  3.7 KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import whrandom
  6. import ObjStore
  7. import GameStateAux
  8.  
  9. def RepeatPeriodicSound(persound):
  10.     if persound.OnPlay:
  11.         persound.sound.PlaySound(0)
  12.         variation = whrandom.uniform(-(persound.frec_variation), persound.frec_variation)
  13.         Bladex.AddScheduledFunc(Bladex.GetTime() + persound.frecuency + variation, RepeatPeriodicSound, (persound,), 'RepeatPeriodicSound')
  14.     
  15.  
  16.  
  17. class PeriodicSound:
  18.     OnPlay = 0
  19.     ObjId = None
  20.     sound = None
  21.     frecuency = 0
  22.     frec_variation = 0
  23.     
  24.     def __init__(self):
  25.         self.ObjId = ObjStore.GetNewId()
  26.         ObjStore.ObjectsStore[self.ObjId] = self
  27.  
  28.     
  29.     def PlayPeriodic(self):
  30.         self.OnPlay = 1
  31.         self.sound.PlaySound(0)
  32.         variation = whrandom.uniform(-(self.frec_variation), self.frec_variation)
  33.         Bladex.AddScheduledFunc(Bladex.GetTime() + self.frecuency + variation, RepeatPeriodicSound, (self,), 'PeriodicSound::PlayPeriodic')
  34.  
  35.     
  36.     def StopPeriodic(self):
  37.         self.OnPlay = 0
  38.  
  39.     
  40.     def persistent_id(self):
  41.         return self.ObjId
  42.  
  43.     
  44.     def __getstate__(self):
  45.         return (1, self.ObjId, self.OnPlay, GameStateAux.SaveEntityAux(self.sound), self.frecuency, self.frec_variation)
  46.  
  47.     
  48.     def __setstate__(self, parm):
  49.         if parm[0] == 1:
  50.             self.ObjId = parm[1]
  51.             ObjStore.ObjectsStore[self.ObjId] = self
  52.             self.sound = GameStateAux.LoadEntityAux(parm[2])
  53.             self.frecuency = parm[3]
  54.             self.frec_variation = parm[4]
  55.         else:
  56.             print 'Warning -> Version mismatch in PeriodicSound.__setstate__()'
  57.             self.OnPlay = 0
  58.             self.sound = None
  59.             self.frecuency = 0
  60.             self.frec_variation = 0
  61.             self.ObjId = ObjStore.GetNewId()
  62.             ObjStore.ObjectsStore[self.ObjId] = self
  63.  
  64.  
  65.  
  66. def CreatePeriodicSound(file_name, sound_name, frecuency, frec_variation, focus):
  67.     persound = PeriodicSound()
  68.     persound.sound = Bladex.CreateEntity(sound_name, 'Entity Sound', focus[0], focus[1], focus[2])
  69.     persound.sound.SetSound(file_name)
  70.     persound.frecuency = frecuency
  71.     persound.frec_variation = frec_variation
  72.     persound.sound.Data = persound
  73.     return persound
  74.  
  75.  
  76. def CreateEntitySound(file_name, sound_name, focus = (0.0, 0.0, 0.0)):
  77.     entsound = Bladex.CreateEntity(sound_name, 'Entity Sound', focus[0], focus[1], focus[2])
  78.     entsound.SetSound(file_name)
  79.     return entsound
  80.  
  81.