annotate gamelib/scenes/cryo.py @ 56:75bf3d3689e9

Refactor thing interactivity and add "fake" bridge scene.
author Jeremy Thurgood <firxen@gmail.com>
date Mon, 23 Aug 2010 13:39:12 +0200
parents 2e2f6ff54780
children 3087be3463e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
1 """Cryo room where the prisoner starts out."""
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
2
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
3 import random
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
4
39
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
5 from gamelib.state import Scene, Item, Thing
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
6
28
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
7
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
8 class Cryo(Scene):
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
9
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
10 FOLDER = "cryo"
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
11 BACKGROUND = "cryo_room.png"
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
12
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
13 INITIAL_DATA = {
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
14 'accessible': True,
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
15 }
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
16
28
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
17 def __init__(self, state):
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
18 super(Cryo, self).__init__(state)
35
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
19 self.add_item(Triangle("triangle"))
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
20 self.add_item(TitaniumLeg("titanium_leg"))
39
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
21 self.add_thing(CryoUnitAlpha("cryo.unit.1", (20, 20, 400, 500)))
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
22 self.add_thing(CryoRoomDoor("cryo.door", (30, 30, 400, 300)))
35
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
23
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
24
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
25 class Triangle(Item):
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
26 "Test item. Needs to go away at some point."
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
27
35
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
28 INVENTORY_IMAGE = "triangle.png"
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
29
ebc76bc0c067 First item!
Simon Cross <hodgestar+bzr@gmail.com>
parents: 28
diff changeset
30
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
31 class TitaniumLeg(Item):
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
32 "Titanium leg, found on a piratical corpse."
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
33
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
34 INVENTORY_IMAGE = "titanium_leg.png"
28
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
35
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
36
39
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
37 class CryoUnitAlpha(Thing):
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
38 pass
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
39
088a101f5b94 Add an example Thing to cryo scene.
Simon Cross <hodgestar+bzr@gmail.com>
parents: 35
diff changeset
40
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
41 class CryoRoomDoor(Thing):
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
42 "Door to the cryo room."
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
43
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
44 FOLDER = "cryo"
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
45 IMAGE = "cryo_door_closed"
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
46
55
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
47 INITIAL_DATA = {
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
48 'open': False,
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
49 }
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
50
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
51 def interact_with_titanium_leg(self, item):
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
52 self.message("You wedge the titanium leg into the chain and twist. With a satisfying *snap*, the chain breaks and the door opens.")
55
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
53 self.open_door()
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
54
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
55 def interact_without(self):
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
56 self.message("It moves slightly and then stops. A chain on the other side is preventing it from opening completely.")
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
57
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
58 def interact_default(self, item):
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
59 self.message(random.choice([
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
60 "Sadly, this isn't that sort of game.",
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
61 "Your valiant efforts are foiled by the Evil Game Designer.",
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
62 "The door resists. Try something else, perhaps?",
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
63 ]))
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
64
56
75bf3d3689e9 Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents: 55
diff changeset
65 def is_interactive(self):
75bf3d3689e9 Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents: 55
diff changeset
66 return not self.get_data('open')
75bf3d3689e9 Refactor thing interactivity and add "fake" bridge scene.
Jeremy Thurgood <firxen@gmail.com>
parents: 55
diff changeset
67
55
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
68 def open_door(self):
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
69 self.set_data('open', True)
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
70 self.state.scenes['bridge'].set_data('accessible', True)
2e2f6ff54780 Part of the cryo door puzzle.
Jeremy Thurgood <firxen@gmail.com>
parents: 41
diff changeset
71
41
ad6f56bfa8b7 Cryo door, titanium leg and some interaction prototypes.
Jeremy Thurgood <firxen@gmail.com>
parents: 39
diff changeset
72
28
0f25f7b9b37a Add loading of initial state.
Simon Cross <hodgestar+bzr@gmail.com>
parents:
diff changeset
73 SCENES = [Cryo]