# Winter Holiday Tag - December project # Game of Tag, extension 1 with Control CodeX import radio from codex import * import ascii_art import time import random # -- Constants -- NUM_PLAYERS = 15 MY_NUM = 300 present = ''' /.=BLACK x=WHITE 0=GREEN #=RED @=ORANGE C=CYAN ....xx.........xx....... ...x##xx.....xx##x...... ...x####xxxxx####x...... ....xx###x#x###xx....... ......x##x#x##x......... .......xxxxxxx@@@....... ...xxxxxxxxxxxxxxx@..... ...x0000x###x0000x.@.... ...x0000x###x0000x.@.... ...xxxxxxxxxxxxxxx.CCC.. ...x0000x###x0000x.CCC.. ...x0000x###x0000x.CCC.. ...x0000x###x0000x.CCC.. ...x0000x###x0000x.CCC.. ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...x0000x###x0000x...... ...xxxxxxxxxxxxxxx...... ''' tag = ascii_art.get_images(present, scale=10) # -- Functions -- def set_pic(have_present): if have_present: display.draw_image(tag[0]) pixels.set([RED, RED, GREEN, GREEN]) else: display.show(pics.TARGET) pixels.off() def end_game(have_present, count): radio.off() if not have_present: display.show(pics.SAD) # -- Set Up -- have_present = False radio.on() radio.config(channel=6) if MY_NUM == 1: have_present = True # -- Play Game -- while True: if have_present and buttons.is_pressed(BTN_U): send_to = MY_NUM while send_to == MY_NUM: send_to = random.randint(1, NUM_PLAYERS) radio.send(str(send_to)) have_present = False set_pic(have_present) if buttons.is_pressed(BTN_D) and MY_NUM == 300: radio.send('Z') display.clear() break msg = radio.receive() if msg: if msg == str(MY_NUM): have_present = True count = count + 1 if msg == 'Z': end_game(have_present) break