Mercurial > boomslang
comparison gamelib/scenes/cryo.py @ 86:593bddfacf18
Refactor Things a bit to render images.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 00:14:23 +0200 |
parents | 6bfebfbce42e |
children | 4c6fea1b242b |
comparison
equal
deleted
inserted
replaced
85:5a7c35f4de8d | 86:593bddfacf18 |
---|---|
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 | 4 |
5 from gamelib.state import Scene, Item, Thing, Result | 5 from gamelib.state import Scene, Item, Thing, Result, \ |
6 InteractImage, InteractNoImage | |
6 | 7 |
7 | 8 |
8 class Cryo(Scene): | 9 class Cryo(Scene): |
9 | 10 |
10 FOLDER = "cryo" | 11 FOLDER = "cryo" |
16 | 17 |
17 def __init__(self, state): | 18 def __init__(self, state): |
18 super(Cryo, self).__init__(state) | 19 super(Cryo, self).__init__(state) |
19 self.add_item(Triangle("triangle")) | 20 self.add_item(Triangle("triangle")) |
20 self.add_item(TitaniumLeg("titanium_leg")) | 21 self.add_item(TitaniumLeg("titanium_leg")) |
21 self.add_thing(CryoUnitAlpha("cryo.unit.1", (20, 20, 200, 200))) | 22 self.add_thing(CryoUnitAlpha()) |
22 self.add_thing(CryoRoomDoor("cryo.door", (200, 200, 400, 300))) | 23 self.add_thing(CryoRoomDoor()) |
23 | 24 |
24 | 25 |
25 class Triangle(Item): | 26 class Triangle(Item): |
26 "Test item. Needs to go away at some point." | 27 "Test item. Needs to go away at some point." |
27 | 28 |
35 | 36 |
36 | 37 |
37 class CryoUnitAlpha(Thing): | 38 class CryoUnitAlpha(Thing): |
38 "Cryo unit containing titanium leg." | 39 "Cryo unit containing titanium leg." |
39 | 40 |
40 FOLDER = "cryo" | 41 NAME = "cryo.unit.1" |
41 IMAGE = "cryo_unit_alpha" | 42 |
43 INTERACTS = { | |
44 "unit": InteractNoImage(100, 300, 100, 100), | |
45 } | |
46 | |
47 INITIAL = "unit" | |
42 | 48 |
43 INITIAL_DATA = { | 49 INITIAL_DATA = { |
44 'contains_titanium_leg': True, | 50 'contains_titanium_leg': True, |
45 } | 51 } |
46 | 52 |
54 | 60 |
55 | 61 |
56 class CryoRoomDoor(Thing): | 62 class CryoRoomDoor(Thing): |
57 "Door to the cryo room." | 63 "Door to the cryo room." |
58 | 64 |
59 FOLDER = "cryo" | 65 NAME = "cryo.door" |
60 IMAGE = "cryo_door_closed" | 66 |
67 INTERACTS = { | |
68 "ajar": InteractImage(200, 200, "door_ajar.png"), | |
69 "open": InteractImage(200, 200, "door_open.png"), | |
70 } | |
71 | |
72 INITIAL = "ajar" | |
61 | 73 |
62 INITIAL_DATA = { | 74 INITIAL_DATA = { |
63 'open': False, | 75 'open': False, |
64 } | 76 } |
65 | 77 |
80 def is_interactive(self): | 92 def is_interactive(self): |
81 return not self.get_data('open') | 93 return not self.get_data('open') |
82 | 94 |
83 def open_door(self): | 95 def open_door(self): |
84 self.set_data('open', True) | 96 self.set_data('open', True) |
97 self.set_interact("open") | |
85 self.state.scenes['bridge'].set_data('accessible', True) | 98 self.state.scenes['bridge'].set_data('accessible', True) |
86 self.state.remove_inventory_item('titanium_leg') | 99 self.state.remove_inventory_item('titanium_leg') |
87 | 100 |
88 def get_description(self): | 101 def get_description(self): |
89 if self.get_data('open'): | 102 if self.get_data('open'): |