2 # 20,000 Light Years Into Space
3 # This game is licensed under GPL v2, and copyright (C) Jack Whitham 2006-07.
8 from pygame
.locals import *
16 cur_time
= time
.time()
17 if (cur_time
-last_time
>1):
18 s
= resource
.Load_Sound(name
) # (comes from a cache)
24 class Persisting_Sound
:
25 def __init__(self
, name
, secondary
=None):
26 self
.sobj
= resource
.Load_Sound(name
)
27 if ( secondary
!= None ):
28 # A different, less annoying mode.
29 self
.sobj2
= resource
.Load_Sound(secondary
)
31 self
.sobj2
= self
.sobj
35 def Set(self
, volume
):
36 if (( self
.sobj
== None )
37 or ( self
.sobj2
== None )):
44 self
.sobj
.set_volume(volume
)
45 self
.sobj2
.set_volume(volume
)
46 if (( self
.schan
== None )
47 or ( not ( self
.schan
.get_sound()
48 in [ self
.sobj
, self
.sobj2
] ))):
49 self
.schan
= self
.sobj
.play()
51 self
.schan
.queue(self
.sobj2
)
54 if (( self
.sobj
== None )
55 or ( self
.sobj2
== None )
56 or ( self
.schan
== None )):
59 self
.schan
.queue(self
.sobj2
)
60 self
.sobj2
.fadeout(200)