def draw_floorplan_test(canvas, locfile, netlist=None, pause=True): chip = Unit("chip", 0, 0, 800, 600) chip.draw(canvas, outline='maroon', width=2, tags=['root', 'chip']) units = read_units(locfile) udict = dict() # unit name lookup table for u in units: u.draw(canvas, tags=['unit', u.name], fill='red', stipple='gray12') udict[u.name] = u #raw_input("Press Enter for placement:") canvas.update() time.sleep(0.5) if netlist is not None: nets = read_nets(netlist, udict) if pause: for n in nets: n.draw(canvas) rootWindow.update() time.sleep(1) canvas.delete(n.name) else: for n in nets: n.draw(canvas) canvas.tag_raise('chip') tk.mainloop()
def make_random_locfile(base_units=None, file=None): from PIL import ImageGrab root = Unit("chip", 0, 0, 800, 600) root.draw(outline='maroon', width=4, tags=['root', 'chip']) if base_units == None: base_units = [root] units = create_random_units(base_units, 9) for u in units: u.draw(tags=['unit']) #print(u.name, u.x1, u.y1, u.x2, u.y2) canvas.tag_raise('chip') rootWindow.update() time.sleep(1) #ImageGrab.grab((0,0,canvas.winfo_width(),canvas.winfo_height())).save("foo.jpg") if not file is None: save_units(units, file) response = raw_input("Continue? (y/n): ") if response == "n": return canvas.delete('unit') for u in units: random_move2(u) u.draw() u.draw(tags=['unit']) if not file is None: save_units(units, file) canvas.delete('text') canvas.tag_raise('chip') rootWindow.update() time.sleep(1) #ImageGrab.grab((0,0,canvas.winfo_width(),canvas.winfo_height())).save("bar.jpg") tk.mainloop()
def random_floor(): root = Unit("chip", 0, 0, 800, 600) root.draw(outline='maroon', width=2, tags=['root', 'chip']) units = random_cell_list(root.x1, root.y1, root.x2, root.y2, 30) for u in units: #u.draw(tags=['unit'], fill='cornsilk', stipple="gray12") u.draw(tags=['unit']) #print(u.name, u.x1, u.y1, u.x2, u.y2) canvas.tag_raise('chip') #rootWindow.update() tk.mainloop()
while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: sys.exit() elif event.key == pygame.K_z: trooper.action() elif event.key == pygame.K_UP: cursor.update('up') elif event.key == pygame.K_DOWN: cursor.update('down') elif event.key == pygame.K_LEFT: cursor.update('left') elif event.key == pygame.K_RIGHT: cursor.update('right') cursor_x, cursor_y = cursor.get_location() trooper.update( cursor_x, cursor_y ) background.draw() trooper.draw() cursor.draw() pygame.display.flip() moveflag = 0 clock.tick(FPS)
for unit in currentMap.enemyUnits: activeEnemyUnits.append(unit) else: screen.fill((0,0,0)) currentMap.draw(screen, xCamera, yCamera) mainCursor.draw(screen) for unit in playerUnits: unit.draw(screen, tileSize, xCamera, yCamera) for enemy in currentMap.enemyUnits: enemy.draw(screen, tileSize, xCamera, yCamera) myMapUnitUI.draw(screen, font) if currentState == states.selectingAttack: myBattleForcast.draw(screen, font, currentUnit, unitsInRange[attackUnitIndex]) elif currentState == states.selectingItems: currentUnit.inventory.draw(screen, font) elif currentState == states.selectingWeapon: currentUnit.inventory.draw(screen, font) elif currentState == states.selectingAction: screen.blit(menuCursor, (gameWidth-450, 240+(165*menuSelectionIndex))) Y = 200 if "attack" in menuOptions: screen.blit(attackButton, (gameWidth - 300, Y))