comparison gamelib/scenes/cryo.py @ 141:4f18e68fd0dc

Add a few sounds to the cryo room
author Neil Muller <neil@dip.sun.ac.za>
date Tue, 24 Aug 2010 22:29:23 +0200
parents d264850806dc
children 29ba5456e8b3
comparison
equal deleted inserted replaced
140:95d882eeba12 141:4f18e68fd0dc
1 """Cryo room where the prisoner starts out.""" 1 """Cryo room where the prisoner starts out."""
2 2
3 import random 3 import random
4 from albow.music import change_playlist, get_music, PlayList
4 5
5 from gamelib import speech 6 from gamelib import speech
7 from gamelib.sound import get_sound
6 from gamelib.cursor import CursorSprite 8 from gamelib.cursor import CursorSprite
7 from gamelib.state import Scene, Item, Thing, Result, \ 9 from gamelib.state import Scene, Item, Thing, Result, \
8 InteractImage, InteractNoImage, InteractRectUnion, \ 10 InteractImage, InteractNoImage, InteractRectUnion, \
9 InteractAnimated 11 InteractAnimated
10 12
16 18
17 INITIAL_DATA = { 19 INITIAL_DATA = {
18 'accessible': True, 20 'accessible': True,
19 'greet' : True 21 'greet' : True
20 } 22 }
23
24 # sounds that will be played randomly as background noise
25 MUSIC = [
26 'drip1.ogg',
27 'drip2.ogg',
28 'creaking.ogg',
29 'silent.ogg',
30 'silent.ogg',
31 ]
21 32
22 def __init__(self, state): 33 def __init__(self, state):
23 super(Cryo, self).__init__(state) 34 super(Cryo, self).__init__(state)
24 self.add_item(TitaniumLeg("titanium_leg")) 35 self.add_item(TitaniumLeg("titanium_leg"))
25 self.add_thing(CryoUnitAlpha()) 36 self.add_thing(CryoUnitAlpha())
26 self.add_thing(CryoRoomDoor()) 37 self.add_thing(CryoRoomDoor())
27 self.add_thing(CryoComputer()) 38 self.add_thing(CryoComputer())
28 39
29 def enter(self): 40 def enter(self):
41 # Setup music
42 pieces = [get_music(x, prefix='sounds') for x in self.MUSIC]
43 background_playlist = PlayList(pieces, random=True, repeat=True)
44 change_playlist(background_playlist)
30 if self.get_data('greet'): 45 if self.get_data('greet'):
31 self.set_data('greet', False) 46 self.set_data('greet', False)
32 return Result("Greetings Prisoner id. You have woken early under" 47 return Result("Greetings Prisoner id. You have woken early under"
33 " the terms of the emergency conscription act to help with" 48 " the terms of the emergency conscription act to help with"
34 " repairs to the ship. Your behaviour during this time will" 49 " repairs to the ship. Your behaviour during this time will"
35 " be added to your record and will be relayed to " 50 " be added to your record and will be relayed to "
36 " prison officials when we reach the destination." 51 " prison officials when we reach the destination."
37 " Please report to the bridge.") 52 " Please report to the bridge.")
38 53
54 def leave(self):
55 # Stop music
56 change_playlist(None)
57
39 58
40 class TitaniumLeg(Item): 59 class TitaniumLeg(Item):
41 "Titanium leg, found on a piratical corpse." 60 "Titanium leg, found on a piratical corpse."
42 61
43 INVENTORY_IMAGE = "titanium_femur.png" 62 INVENTORY_IMAGE = "titanium_femur.png"
101 self.open_door() 120 self.open_door()
102 return Result("You wedge the titanium femur into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.") 121 return Result("You wedge the titanium femur into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.")
103 elif self.get_data('door') == "shut": 122 elif self.get_data('door') == "shut":
104 text = "You bang on the door with the titanium femur. It makes a clanging sound." 123 text = "You bang on the door with the titanium femur. It makes a clanging sound."
105 speech.say(self.name, text) 124 speech.say(self.name, text)
106 return Result(text) 125 return Result(text, soundfile='clang.ogg')
107 else: 126 else:
108 return Result("You wave the femur in the doorway. Nothing happens.") 127 return Result("You wave the femur in the doorway. Nothing happens.")
109 128
110 def interact_without(self): 129 def interact_without(self):
111 if self.get_data('door') == "shut": 130 if self.get_data('door') == "shut":