Example #1
0
def process_message(msg):
    if msg['type'] == 'def_playfield':
        appendPlayfield(msg)
    elif msg['type'] == 'def_icon':
        sm.add_icon(msg['icon_code'], msg['filename'])
    elif msg['type'] == 'ns':
        sm.add_sprite(msg['s'], msg['icon_code'], msg['x'], msg['y'])
        sm.set_z_index(msg['s'], msg['z'])
    elif msg['type'] == 'sm':
        sm.move_sprite(msg['s'], msg['x'], msg['y'])
        sm.set_z_index(msg['s'], msg['z'])
    elif msg['type'] == 'ds':
        sm.hide_sprite(msg['s'])
    elif msg['type'] == 'begin_clean_sprites':
        sm.start_clean_sprites()
    elif msg['type'] == 'clean_sprites':
        sm.end_clean_sprites()
    elif msg['type'] == 'show_sprite':
        sm.show_sprite(msg['s'], msg['icon_code'], msg['x'], msg['y'])
    elif msg['type'] == 'zindex':
        sm.set_z_index(msg['s'], msg['z'])
    #elif msg['type'] == 'ss':
    #    sm.show_sprite(msg['s'])
    elif msg['type'] == 'player_icon' or msg['type'] == 'def_key' or \
         msg['type'] == 'player_join' or msg['type'] == 'player_kill':
        pass  #ignore
    else:
        logWarning('unknown message type: ' + msg['type'])
Example #2
0
def keyup(key):
    key = key._event
    c = key.keyCode
    if c > ord('0') and c < ord('9'):
        pass  #don't print warning
    elif c in km.keymappings:
        km.add_key_up(km.keymappings[c])
    else:
        logWarning('unknown keyup: ' + str(c))