You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Zombie-House/README.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,11 @@ Remix from [original RPG project](https://projects.raspberrypi.org/en/projects/r
9
9
* Functions
10
10
* Lists
11
11
* Dictionaries
12
-
* Game Loop
12
+
* if / else
13
+
* for loop
14
+
* A "game loop" (using "while True:")
15
+
* Formatted String Literals (f-strings)
16
+
* try / except
13
17
14
18
**Objectives:**
15
19
@@ -29,6 +33,31 @@ rooms = {
29
33
}
30
34
}
31
35
```
36
+
In order to improve the navigation and display the available directions the player can travel, a nested dictionary was introduced so that directions and items are separated (this also fixed a bug in the game).
37
+
38
+
```python
39
+
rooms = {
40
+
41
+
'Hall' : {
42
+
'directions' : {
43
+
'south' : 'Kitchen',
44
+
'east' : 'Dining Room',
45
+
'north' : 'Atrium',
46
+
'west' : 'Library'
47
+
},
48
+
'item' : 'key'
49
+
},
50
+
51
+
'Kitchen' : {
52
+
'directions' : {
53
+
'north' : 'Hall',
54
+
'east' : 'Pantry'
55
+
},
56
+
'monster' : 'Zombie',
57
+
'item' : 'flower'
58
+
},
59
+
```
60
+
32
61
Going beyond the original project, this example introduces two new types of objects inside a room: *monster*and*poison*- each being displayed inside the room with the following code:
0 commit comments