Skip to content

Commit 8ebf84e

Browse files
authored
Merge pull request #2 from dastels/master
Some renaming
2 parents f0a920d + f7e9b94 commit 8ebf84e

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

adafruit_pyoa.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _wait_for_press(self, card):
197197
198198
:param card: The active card
199199
200-
Return the id of the destination page.
200+
Return the id of the destination card.
201201
"""
202202
button01_text = card.get('button01_text', None)
203203
button02_text = card.get('button02_text', None)
@@ -209,25 +209,25 @@ def _wait_for_press(self, card):
209209
# showing only middle button
210210
if self._middle_button.contains(point_touched):
211211
print("Middle button")
212-
return card.get('button01_goto_page_id', None)
212+
return card.get('button01_goto_card_id', None)
213213
if button01_text and button02_text:
214214
if self._left_button.contains(point_touched):
215215
print("Left button")
216-
return card.get('button01_goto_page_id', None)
216+
return card.get('button01_goto_card_id', None)
217217
if self._right_button.contains(point_touched):
218218
print("Right button")
219-
return card.get('button02_goto_page_id', None)
219+
return card.get('button02_goto_card_id', None)
220220

221221
def display_card(self, card_num):
222-
"""Display and handle input on a page.
222+
"""Display and handle input on a card.
223223
224224
:param card_num: the index of the card to process
225225
226226
"""
227227
card = self._game[card_num]
228228
print(card)
229229
print("*"*32)
230-
print('****{:^24s}****'.format(card['page_id']))
230+
print('****{:^24s}****'.format(card['card_id']))
231231
print("*"*32)
232232

233233
self._fade_to_black()
@@ -248,14 +248,14 @@ def display_card(self, card_num):
248248
time.sleep(auto_adv)
249249
return card_num+1
250250

251-
destination_page_id = self._wait_for_press(card)
251+
destination_card_id = self._wait_for_press(card)
252252

253253
self.play_sound(None) # stop playing any sounds
254-
for page_number, page_struct in enumerate(self._game):
255-
if page_struct.get('page_id', None) == destination_page_id:
256-
return page_number # found the matching card!
254+
for card_number, card_struct in enumerate(self._game):
255+
if card_struct.get('card_id', None) == destination_card_id:
256+
return card_number # found the matching card!
257257
# eep if we got here something went wrong
258-
raise RuntimeError("Could not find card with matching 'page_id': ", destination_page_id)
258+
raise RuntimeError("Could not find card with matching 'card_id': ", destination_card_id)
259259

260260
def play_sound(self, filename, *, wait_to_finish=True, loop=False):
261261
"""Play a sound

examples/cyoa/cyoa.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
[
22
{
3-
"page_id": "startup",
3+
"card_id": "startup",
44
"background_image": "startup.bmp",
55
"sound": "startup.wav",
66
"auto_advance": "5"
77
},
88
{
9-
"page_id": "home",
9+
"card_id": "home",
1010
"background_image": "home.bmp",
1111
"sound": "home.wav",
1212
"sound_repeat": "True",
1313
"button01_text": "Help",
14-
"button01_goto_page_id": "help",
14+
"button01_goto_card_id": "help",
1515
"button02_text": "Start",
16-
"button02_goto_page_id": "1"
16+
"button02_goto_card_id": "want to build?"
1717
},
1818

1919
{
20-
"page_id": "1",
20+
"card_id": "want to build?",
2121
"background_image": "page01.bmp",
2222
"text": "You do not have any friends so you decide that it might be a good idea to build a robot friend. You're unsure if you want to do this, so now is the time to decide. Do you want to build a robot friend?",
2323
"text_color": "0x000001",
2424
"sound": "sound_01.wav",
2525
"button01_text": "Yes",
26-
"button01_goto_page_id": "2",
26+
"button01_goto_card_id": "continue?",
2727
"button02_text": "No",
28-
"button02_goto_page_id": "4"
28+
"button02_goto_card_id": "lazy"
2929
},
3030
{
31-
"page_id": "2",
31+
"card_id": "continue?",
3232
"background_image": "page02.bmp",
3333
"text": "You spend all day, then all week, then all month building a robot, everyone stops talking to you, however a lot of progress has been made. Do you want to keep making the robots?",
3434
"text_color": "0xFFFFFF",
3535
"button01_text": "Yes",
36-
"button01_goto_page_id": "3",
36+
"button01_goto_card_id": "robot friend",
3737
"button02_text": "No",
38-
"button02_goto_page_id": "4"
38+
"button02_goto_card_id": "lazy"
3939
},
4040
{
41-
"page_id": "3",
41+
"card_id": "robot friend",
4242
"background_image": "page03.bmp",
4343
"text": "The robot is now you're friend, everyone else wishes they had a robot, this is the best thing ever. Good work!",
4444
"text_color": "0xFFFFFF",
4545
"sound": "sound_03.wav",
4646
"button01_text": "Next",
47-
"button01_goto_page_id": "happy_ending"
47+
"button01_goto_card_id": "happy ending"
4848
},
4949
{
50-
"page_id": "4",
50+
"card_id": "lazy",
5151
"background_image": "page04.bmp",
5252
"sound": "sound_04.wav",
5353
"text": "Welp, not only will you not have any friends, you are lazy. What's the point of playing? Try again.",
5454
"text_color": "0xFFFFFF",
5555
"button01_text": "Start Over",
56-
"button01_goto_page_id": "home"
56+
"button01_goto_card_id": "home"
5757
},
5858
{
59-
"page_id": "help",
59+
"card_id": "help",
6060
"background_image": "help.bmp",
6161
"text": "All you need to do is click the buttons, that's it.\nThis is a new line.",
6262
"text_color": "0xFFFFFF",
6363
"button01_text": "Home",
64-
"button01_goto_page_id": "home"
64+
"button01_goto_card_id": "home"
6565
},
6666
{
67-
"page_id": "happy_ending",
67+
"card_id": "happy ending",
6868
"background_image": "happyending.bmp",
6969
"sound": "happy_ending.wav",
7070
"sound_repeat": "True",
7171
"button01_text": "Home",
72-
"button01_goto_page_id": "home"
72+
"button01_goto_card_id": "home"
7373
}
7474
]

0 commit comments

Comments
 (0)