def create_window(size): graphics.init() fullscreen = features.get('ui.fullscreen') if fullscreen: size = graphics.get_screen_size() graphics.create_window(size, fullscreen=fullscreen) if features.get('ui.offscreen'): graphics.set_offscreen_window(size)
def init_screen(): global screen, surface, overview_surface if osutil.is_desktop: # on Android android.pyx takes care of init graphics.init() graphics.create_window((1280, 800)) screen = graphics.get_window() surface = screen
model = TechtreeClientModel(client) widget = TechTreeWidget(model, *tree) widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.set(widget) if __name__ == '__main__': tree = load_techtree('data/techtree.index') class ExampleModel: def is_researched(self, name): name = name.strip("'") return name in [ 'Alphabet', 'Masonry', 'Currency', 'Bronze Working', 'Mathematics' ] def is_available(self, name): return False model = ExampleModel() graphics.init() ui.init() wnd = graphics.create_window((800, 600)) ui.screen_width, ui.screen_height = ui.screen_size = wnd.get_size() widget = TechTreeWidget(model, *tree) widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.replace(widget) ui.main()
def show(client): tree = load_techtree('data/techtree.index') model = TechtreeClientModel(client) widget = TechTreeWidget(model, *tree) widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.set(widget) if __name__ == '__main__': tree = load_techtree('data/techtree.index') class ExampleModel: def is_researched(self, name): name = name.strip("'") return name in ['Alphabet', 'Masonry', 'Currency', 'Bronze Working', 'Mathematics'] def is_available(self, name): return False model = ExampleModel() graphics.init() ui.init() wnd = graphics.create_window((800, 600)) ui.screen_width, ui.screen_height = ui.screen_size = wnd.get_size() widget = TechTreeWidget(model, *tree) widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.replace(widget) ui.main()
if __name__ == '__main__': WALL = "x" SP = "S" # staring point EP = "E" # ending point PATH = "*" # path EM = "o" # empty space d_move = True # diagonal movement on/off ERROR_MESSAGE = "Not a valid position" window_x = 1280 window_y = 720 grid_x = 16 grid_y = 12 start_pos = (0, grid_y // 2) end_pos = (grid_x - 1, grid_y // 2) window = gg.create_window(window_x, window_y) correct_path = [] previous_path = [] grid = gr.Grid(window, grid_x, grid_y, start_pos, end_pos) # initial grid gg.draw_grid(window, grid) while True: # find all possible shortest paths paths = gf.find_paths(grid, start_pos, end_pos, WALL, d_move) # if there are any possible paths if gf.is_solvable(paths): # create a new grid with the distances gf.distance_map(grid, paths) # create a list of points that forms the correct path correct_path = gf.generate_path(start_pos, end_pos, grid, d_move)