(g, smallmap=False, flipbuttons=False, flipsounds=False)
Turn a game upside down.

    This modifies the game in-place.

    Args:
      g: The Game to turn upside down.
      smallmap: True if the gfx/map shared region is used as gfx, False
        otherwise.
      flipbuttons: If True, reverses functions regarding reading buttons
        to swap left and right, up and down.
      flipsounds: If True, reverses sound effect / music pattern data.
Turn a game upside down.
Turn a game upside down .
def upsidedown_game(g, smallmap=False, flipbuttons=False, flipsounds=False):
    """Turn a game upside down.

    This modifies the game in-place.

    Args:
      g: The Game to turn upside down.
      smallmap: True if the gfx/map shared region is used as gfx, False
        otherwise.
      flipbuttons: If True, reverses functions regarding reading buttons
        to swap left and right, up and down.
      flipsounds: If True, reverses sound effect / music pattern data.
    """
    last_sprite = 256 if smallmap else 128
    for id in range(last_sprite):
        sprite = g.gfx.get_sprite(id)
        flipped_sprite = reversed(list(reversed(row) for row in sprite))
        g.gfx.set_sprite(id, flipped_sprite)

    last_map_row = 32 if smallmap else 64
    tile_rect = g.map.get_rect_tiles(0, 0, 128, last_map_row)
    flipped_map = reversed(list(reversed(row) for row in tile_rect))
    g.map.set_rect_tiles(flipped_map, 0, 0)

    if flipsounds:
        for id in range(63):
            notes = [g.sfx.get_note(id, n) for n in range(32)]
            notes.reverse()
            for n in range(32):
                g.sfx.set_note(id, n, *notes[n])
            (editor_mode, note_duration, loop_start,
             loop_end) = g.sfx.get_properties(id)
            if loop_start:
                g.sfx.set_properties(id, loop_start=63-loop_end)
            if loop_end:
                g.sfx.set_properties(id, loop_end=63-loop_start)

    transform = UpsideDownASTTransform(g.lua.tokens, g.lua.root,
                                       smallmap=smallmap,
                                       flipbuttons=flipbuttons)
    try:
        it = transform.walk()
        while True:
            it.__next__()
    except StopIteration:
        pass
def upsidedown_game ( g , smallmap = False , flipbuttons = False , flipsounds = False ) : last_sprite = 256 if smallmap else 128 for id in range ( last_sprite ) : sprite = g . gfx . get_sprite ( id ) flipped_sprite = reversed ( list ( reversed ( row ) for row in sprite ) ) g . gfx . set_sprite ( id , flipped_sprite ) last_map_row = 32 if smallmap else 64 tile_rect = g . map . get_rect_tiles ( 0 , 0 , 128 , last_map_row ) flipped_map = reversed ( list ( reversed ( row ) for row in tile_rect ) ) g . map . set_rect_tiles ( flipped_map , 0 , 0 ) if flipsounds : for id in range ( 63 ) : notes = [ g . sfx . get_note ( id , n ) for n in range ( 32 ) ] notes . reverse ( ) for n in range ( 32 ) : g . sfx . set_note ( id , n , * notes [ n ] ) ( editor_mode , note_duration , loop_start , loop_end ) = g . sfx . get_properties ( id ) if loop_start : g . sfx . set_properties ( id , loop_start = 63 - loop_end ) if loop_end : g . sfx . set_properties ( id , loop_end = 63 - loop_start ) transform = UpsideDownASTTransform ( g . lua . tokens , g . lua . root , smallmap = smallmap , flipbuttons = flipbuttons ) try : it = transform . walk ( ) while True : it . __next__ ( ) except StopIteration : pass