comparison gamelib/scenes/engine.py @ 436:6e1ad25a7db5

Hook up engine room computer console.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 28 Aug 2010 23:55:12 +0200
parents 19aff54b2e73
children cfcab3796410
comparison
equal deleted inserted replaced
435:19aff54b2e73 436:6e1ad25a7db5
1 """Engine room where things need to be repaired.""" 1 """Engine room where things need to be repaired."""
2 2
3 from albow.resource import get_image
3 from gamelib.cursor import CursorSprite 4 from gamelib.cursor import CursorSprite
4 from gamelib.state import Scene, Item, Thing, Result 5 from gamelib.state import Scene, Item, Thing, Result
5 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, 6 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
6 InteractRectUnion, InteractImage, 7 InteractRectUnion, InteractImage,
7 InteractAnimated, GenericDescThing, 8 InteractAnimated, GenericDescThing,
32 self.add_thing(ArrowsBottomLeft()) 33 self.add_thing(ArrowsBottomLeft())
33 self.add_thing(ArrowsRight()) 34 self.add_thing(ArrowsRight())
34 self.add_thing(DangerSign()) 35 self.add_thing(DangerSign())
35 self.add_thing(Stars()) 36 self.add_thing(Stars())
36 self.add_thing(CrackedPipe()) 37 self.add_thing(CrackedPipe())
38 self.add_thing(ComputerConsole())
37 self.add_thing(ToMap()) 39 self.add_thing(ToMap())
38 self.add_thing(GenericDescThing('engine.body', 1, 40 self.add_thing(GenericDescThing('engine.body', 1,
39 "Dead. Those cans must have been past their sell-by date.", 41 "Dead. Those cans must have been past their sell-by date.",
40 ( 42 (
41 (594, 387, 45, 109), 43 (594, 387, 45, 109),
46 "A control panel. It seems dead.", 48 "A control panel. It seems dead.",
47 ( 49 (
48 (513, 330, 58, 50), 50 (513, 330, 58, 50),
49 ) 51 )
50 )) 52 ))
51 self.add_thing(GenericDescThing('engine.computer_console', 3,
52 "A computer console. It seems dead.",
53 (
54 (293, 287, 39, 36),
55 )
56 ))
57 self.add_thing(GenericDescThing('engine.superconductors', 4, 53 self.add_thing(GenericDescThing('engine.superconductors', 4,
58 "Superconductors. The engines must be power hogs.", 54 "Superconductors. The engines must be power hogs.",
59 ( 55 (
60 (679, 246, 50, 56), 56 (679, 246, 50, 56),
61 (473, 280, 28, 23), 57 (473, 280, 28, 23),
62 (381, 224, 25, 22), 58 (381, 224, 25, 22),
63 ) 59 )
64 )) 60 ))
65 self.add_thing(GenericDescThing('engine.floor_hole', 5, 61 self.add_thing(GenericDescThing('engine.floor_hole', 5,
66 "A gaping hole in the floor of the room. I'm guessing that's why there's a vacuum in here.", 62 "A gaping hole in the floor of the room. You're guessing that's why there's a vacuum in here.",
67 ( 63 (
68 (257, 493, 141, 55), 64 (257, 493, 141, 55),
69 (301, 450, 95, 45), 65 (301, 450, 95, 45),
70 (377, 422, 19, 29), 66 (377, 422, 19, 29),
71 (239, 547, 123, 39), 67 (239, 547, 123, 39),
455 INITIAL = 'stars' 451 INITIAL = 'stars'
456 452
457 def is_interactive(self): 453 def is_interactive(self):
458 return False 454 return False
459 455
456 def get_description(self):
457 return "A gaping hole in the floor of the room. You're guessing" \
458 " that's why there's a vacuum in here."
459
460 460
461 class CrackedPipe(Thing): 461 class CrackedPipe(Thing):
462 NAME = "engine.cracked_pipe" 462 NAME = "engine.cracked_pipe"
463 463
464 INTERACTS = { 464 INTERACTS = {
488 self.set_interact('taped') 488 self.set_interact('taped')
489 return Result("You apply your trusty duct tape to the " 489 return Result("You apply your trusty duct tape to the "
490 "creak, sealing it.") 490 "creak, sealing it.")
491 491
492 492
493 class ComputerConsole(Thing):
494 NAME = "engine.computer_console"
495
496 INTERACTS = {
497 'console': InteractNoImage(293, 287, 39, 36),
498 }
499
500 INITIAL = 'console'
501
502 def interact_without(self):
503 return Result(detail_view='engine_comp_detail')
504
505 def get_description(self):
506 return "A computer console. It's alarmingly close to the engine."
507
508
509 class EngineCompDetail(Scene):
510
511 FOLDER = "engine"
512 BACKGROUND = "engine_comp_detail.png"
513 NAME = "engine_comp_detail"
514
515 SIZE = (640, 400)
516
517 ALERTS = {
518 'cryo leaking' : 'ec_cryo_leaking.png',
519 'cryo empty' : 'ec_cryo_reservoir_empty.png',
520 'super malfunction' : 'ec_cryo_super_malfunction.png',
521 }
522
523 # Point to start drawing changeable alerts
524 ALERT_OFFSET = (16, 100)
525 ALERT_SPACING = 4
526
527 def __init__(self, state):
528 super(EngineCompDetail, self).__init__(state)
529
530 self._alert_messages = {}
531 for key, name in self.ALERTS.iteritems():
532 self._alert_messages[key] = get_image(self.FOLDER, name)
533
534 def _draw_alerts(self, surface):
535 xpos, ypos = self.ALERT_OFFSET
536 if not self.state.scenes['engine'].things['engine.cracked_pipe'].get_data('fixed'):
537 image = self._alert_messages['cryo leaking']
538 surface.blit(image, (xpos, ypos))
539 ypos += image.get_size()[1] + self.ALERT_SPACING
540 if not self.state.scenes['engine'].things['engine.cryo_containers'].get_data('filled'):
541 image = self._alert_messages['cryo empty']
542 surface.blit(image, (xpos, ypos))
543 ypos += image.get_size()[1] + self.ALERT_SPACING
544 if not self.state.scenes['engine'].things['engine.superconductor'].get_data('working'):
545 image = self._alert_messages['super malfunction']
546 surface.blit(image, (xpos, ypos))
547 ypos += image.get_size()[1] + self.ALERT_SPACING
548
549 def draw_things(self, surface):
550 self._draw_alerts(surface)
551 super(EngineCompDetail, self).draw_things(surface)
552
553
493 class ToMap(Door): 554 class ToMap(Door):
494 555
495 SCENE = "engine" 556 SCENE = "engine"
496 557
497 INTERACTS = { 558 INTERACTS = {
503 def get_description(self): 564 def get_description(self):
504 return "The airlock leads back to the rest of the ship." 565 return "The airlock leads back to the rest of the ship."
505 566
506 567
507 SCENES = [Engine] 568 SCENES = [Engine]
569 DETAIL_VIEWS = [EngineCompDetail]