Пример #1
0
def main(options):
    pygame.init()
    screen = pygame.display.set_mode((800, 600), pygame.SRCALPHA)
    # load map tiles...
    tiles.find_tiles()
    # load map... (can be called again(?) to change to a new map...)
    load_map.load_map("test_map")

    v = vehicle.rcx()
    clock = pygame.time.Clock()

    while True:
        clock.tick(30)

        events = pygame.event.get()

        for event in events:
            if event.type == QUIT:
                pygame.quit()
                return None
            elif event.type == MOUSEBUTTONDOWN and event.button == 1:
                logger.info(map.map.click_engine(event.pos))

            elif event.type == KEYDOWN:
                if event.key == config.keymap["open_menu"]:
                    ##to be changed later to actually open a main menu like thingy with save and stuff...
                    config.change_config(screen)

                elif event.key == config.keymap["open_programmer"]:
                    ##warning:: blocking code
                    v.code = programmer.create_programming_gui(screen, v.code)
                elif event.key == K_x:
                    # import cPickle as pickle
                    f = open("data/saves/test.pkl", "wb")
                    p = pickle.Pickler(f, 0)
                    p.dump(map.map)
                    p.dump(v)
                    f.close()
                elif event.key == K_z:
                    # import cPickle as pickle
                    f = open("data/saves/test.pkl", "rb")
                    unp = pickle.Unpickler(f)
                    map.map = unp.load()
                    v = unp.load()
                    f.close()
        ##we clear the screen after events because anything that can occur in the events should be 'blocking'
        ##meaning that they actualy run thier own loop for a bit
        screen.fill((0, 0, 0))

        map.map.draw(screen)
        map.map.update_overlays(screen)

        v.events(events)
        v.draw(screen)

        pygame.display.flip()
Пример #2
0
                    ##click hits drag location on tile
                    input.mouse.cur_sel = pmap.map[map_pos][0].drag(pmap)
                    pmap.render()
                
                elif map_pos == (-1,-1):
                    ##we are off the map, lets check if the interface needs anything...
                    
                    ##try to make a button, remove whatever is __in__ the mouse right now
                    ##moved button ccreation to intrface, should have been its job from start
                    intr.click_engine(event.pos)
                    
                
        intr.event_engine(events,pmap)
        if input.mouse.cur_sel:
            input.mouse.cur_sel.draw(screen,input.mouse.cur_pos())
        
        
        pygame.display.flip()




if __name__ == '__main__':
    pygame.init()
    lib.common.debug(2)
    screen = pygame.display.set_mode((800, 600))
    #load map tiles...
    import tiles
    tiles.find_tiles()
    
    create_programming_gui(screen,None)