def get_hunts(): try: with requests.Session() as session: session.cookies.set('PHPSESSID', settings.Settings().phpsessid) r = session.get('http://www.jotihunt.net/groep/hunts.php') scraper = webscraper.TableHTMLParser() scraper.feed(r.text) with open('hunts.log', 'w') as f: f.write(r.text) scraper.fix_tables() # scraper.print_tables() return scraper.tables[0], [ 'hunttijd', 'meldtijd', 'code', 'status', 'toelichting', 'punten' ], 'code' except Exception as e: import Updates Updates.get_updates().error(e, 'get_hunts') return [], [ 'hunttijd', 'meldtijd', 'code', 'status', 'toelichting', 'punten' ], 'code'
def rungame(): pygame.init() score = 0 game_settings = settings.Settings() screen = pygame.display.set_mode( (game_settings.screen_w, game_settings.screen_h)) sb = scoreboard.Scoreboard(screen, score) ship = Ship(screen, game_settings) d_n_f = dnf.Dnf(screen, game_settings) play_button = Button(screen, 'PLAY') exit_button = Button(screen, 'exit') pygame.display.set_caption("avoid the dnfs!") while game_running: gf.check_events(ship) d_n_f.update(game_settings, score, sb, ship, game_running, hs, exit_button) sb.update(score, hs) ship.update(game_settings) gf.update_screen(screen, game_settings, ship, d_n_f, sb)
def settings_window(root: Tk, options: StarterConfig) -> None: '''Display the settings window''' # Settings window is fixed size root.state("normal") root.overrideredirect(False) # show titlebar root.resizable(False, False) root.geometry("") # allow automatic size def sb_run_cb(): event_list = load_cts_startlists(options.get_str("start_list_dir")) board = starter_window(root, options, event_list) # TODO: Fix testing def sb_test_cb(): board = starter_window(root, options) #_set_test_data(board) # Invisible container that holds all content content = settings.Settings(root, sb_run_cb, sb_test_cb, options) content.grid(column=0, row=0, sticky="news")
def run_game(self): # new a setting object game_setting = settings.Settings() # init the game and create the screen pygame.init() screen = pygame.display.set_mode((game_setting.screen_width, game_setting.screen_hight)) pygame.display.set_caption("Alien Invation") # give it a background color bg_color = game_setting.bg_color my_ship = ship.Ship(screen) # create a ship # ship = ship.Ship() # start the main loop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() screen.fill(bg_color) my_ship.blitme() # here refresh the display inside the while loop pygame.display.flip()
def __init__(self): pygame.init() # Get all setings variables from the settings class self.settings = settings.Settings() #Setting up the window self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) pygame.display.set_caption(self.settings.window_caption) self.bg = pygame.image.load(self.settings.bg_image) # Setting the ship self.ship = ship.Ship(self) # Setting a sprite group to handle bullets self.bullets = pygame.sprite.Group() # Setting a sprite group to handle aliens self.aliens = pygame.sprite.Group() #Setting an alien fleet self.create_fleet()
def run_game(): # 初始化游戏并创建一个屏幕对象 # 实例化类 ai_settings = settings.Settings() pygame.init() screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Alien Invasion") # 创建一个船的实例 aship = ship.Ship(ai_settings, screen) # 创建一个用于存储子弹的编组 bullets = pygame.sprite.Group() # 创建一个用于储存外星人的编组 aliens = pygame.sprite.Group() # 创建一个外星人群 gf.create_fleet(ai_settings, screen, aliens, aship) # 创建一个用于统计游戏信息的实例 game_stats = geme_stats.GameStats(ai_settings) #绘制play按钮 play_button = button.Button(screen, "Play") #实例化scoreboard sb = scoreboard.Scoreboard(screen, ai_settings, game_stats) # 开始游戏的主循环 while True: # 监视键盘和鼠标的实践 gf.check_events(ai_settings, screen, aship, bullets, game_stats, play_button, aliens, sb) if game_stats.game_active: # 检查键盘输入,调整飞船的位置,此条代码是更新ship的位置数据 aship.update() # 调入子弹更新和删除无用的子弹,此条代码是更新bullet的数量数据 gf.update_bullets(ai_settings, screen, aliens, aship, bullets, game_stats, sb) # 更新外星人 gf.update_aliens(ai_settings, game_stats, aliens, bullets, screen, aship, sb) # 调入屏幕更新和飞船更新函数,每次重画面 gf.update_screen(ai_settings, screen, aship, bullets, aliens, game_stats, play_button, sb)
def main(): pygame.init() screen = pygame.display.set_mode((480,240)) gradient.fill_gradient(screen, (250,0,20), (0,0,250)) if not pygame.font: print 'Warning, fonts disabled' appSettings = settings.Settings("freesans") dialog1 = Dialog("Quit? (y/n)", "Y", appSettings) dialog1.setTextCenter(screen) dialog1.saveBackground(screen) time.sleep(2) dialog1.show(screen) time.sleep(3) dialog1.restoreBackground(screen) time.sleep(2) sys.exit()
def show_text(screen, font, is_clearance, flag=False): ai_settings = settings.Settings() clock = pygame.time.Clock() msg = 'Game Over!' if not is_clearance else 'Congratulations, you won!' if not is_clearance: positions = [[235, 233], [65, 303], [170, 333]] else: positions = [[145, 233], [65, 303], [170, 333]] surface = pygame.Surface((400, 200)) surface.set_alpha(10) surface.fill((128, 128, 128)) screen.blit(surface, (100, 200)) texts = [ font.render(msg, True, ai_settings.white), font.render('Press ENTER to continue or play again.', True, ai_settings.white), font.render('Press ESC to quit.', True, ai_settings.white) ] while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() pygame.quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: if is_clearance: if not flag: return else: pp.run_game() else: pp.run_game() elif event.key == pygame.K_ESCAPE: sys.exit() pygame.quit() for idx, (text, position) in enumerate(zip(texts, positions)): screen.blit(text, position) pygame.display.flip() clock.tick(10)
def calculateMirrorPoints(self, particle, betaStart, betaEnd, betaStep, alpha=0.5): import csv from plot_probe import _extract s = settings.Settings() beta = betaStart mirrors = [] while beta < betaEnd: s.outfile = self.filename(particle, alpha, beta, 2.0, 1) t, x, y, z = _extract(s.outpath()) mirrors.append([beta, np.max(z), np.min(z)]) beta += betaStep s.outfile = self.filename(particle, 0, 0, 0, 0, 'sine_mirrors_') with open(s.outpath(), 'w') as f: writer = csv.writer(f, delimiter=' ') writer.writerows(mirrors)
def calculateLinearRegression(self, particle, alpha): from numpy import linalg import csv from plot_utility import extractData s = settings.Settings() s.outfile = self.filename(particle, alpha) z = [] t = [] m = 0.0 c = 0.0 with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) R = np.hypot(np.array(x), np.array(y)) A = np.vstack([t, np.ones(len(t))]).T m, c = linalg.lstsq(A, R)[0] s.outfile = self.filename(particle, alpha, 'drift_linreg_') with open(s.outpath(), 'w') as f: writer = csv.writer(f, delimiter=' ') for i in xrange(len(t)): writer.writerow([t[i], m * t[i] + c, z[i]])
def __init__(self): # initialize parameters self.settings = settings.Settings() self.width = self.settings.WIDTH self.height = self.settings.HEIGHT self.bg_color = self.settings.bg_color self.p_red = 0 self.p_green = 0 self.p_blue = 0 # initialize the screen self.screen = pygame.display.set_mode((self.width, self.height)) pygame.display.set_caption("Particle Explosion") self.screen_rect = self.screen.get_rect() # initialize the particles self.particle_group = particles.sprite.Group() self.create_particles() # initialize run speed self.FPS = 60 self.clock = pygame.time.Clock()
def on_new_user(bot, update): if update.message.new_chat_member: if update.message.new_chat_member.username: username = '******' + update.message.new_chat_member.username else: username = update.message.new_chat_member.first_name chatname = update.message.chat.title if authenticator.authenticate_chat(update.message.new_chat_member.id, update.message.chat_id, settings.Settings().SLEUTEL, username=username, chat_naam=chatname): bot.sendMessage( update.message.chat_id, 'welkom ' + username + ' \n Je bent geregistreerd als gebruiker van de ' 'RP Je kunt nu de bot gebruiken. /help') else: bot.sendMessage( update.message.chat_id, 'Welkom' + username + 'Deze chat is niet geverifieërd als chat van de ' 'RP stuur een berichtje naar de HB om je te ' 'registreren.')
def load(config_file): sys.stderr.write("hello there from inside load method ..{0}..\n\n\n ".format(config_file)) # try: # f = open(config_file, 'r') # except ExceInside service class of cm2web from my CGI script.ption as e: # sys.exit('ERROR loading config file. "' + str(e) + '"') try: print("Trying to open file",config_file); server_config = settings.Settings(type= "Services",filepath = config_file) # server_config = json.load(f) except Exception as e: sys.exit('ERROR loading server config "' + str(e) + '"') # f.close() services = {} for service_config in server_config: service = Service.load(service_config) services[service.name] = service return Server(services)
def plotSuperimposed(self, alpha, beta, L, n): s = settings.Settings() field = SineField() field.alpha = alpha field.beta = beta field.L = L field.n = n for particle in self.particles: outfile = self.filename(particle, alpha, beta, L, n) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) #start = len(z) / 4 + 250 #end = len(z) / 4 + 180 start = 0 end = len(z) plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) xmin, xmax = [-0.4, 0.4] ymin, ymax = [0.1, 0.3] # xmin, xmax = plt.xlim() # ymin, ymax = plt.ylim() self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') # plt.text(0.25, 0.8, r'$B_z = B_{z0} \left( 1 + \alpha r + \beta z\ \sin (\frac{n \pi z}{L}) \right)$', # fontsize=15) # plt.text(0.25, 0.7, '$\\alpha = {alp},\\ \\beta = {beta}$'.format(alp=alpha, beta=beta), # fontsize=15) plt.tight_layout() s.outext = '.pdf' plt.savefig(s.outpath()) plt.show()
def calculateDifference(self, alpha): from os import path import csv from plot_utility import extractData app = mag.Application() Bz0 = app.fieldBaseStrength[2] Ek = app.kineticEnergy s = settings.Settings() for particle in self.particles: xdiff = [] ydiff = [] zdiff = [] tlist = [] with open( path.join(s.outdir, self.filename(particle, alpha)) + s.outext) as f: tlist, x, y, z = extractData(f, [0, 1, 2, 3]) self.prepareAnalytic(Ek, self.mass(particle)) for i in xrange(len(tlist)): xa, ya, za = self.analytic(tlist[i], Bz0, self.charge(particle), self.mass(particle)) xdiff.append(xa - x[i]) ydiff.append(ya - y[i]) zdiff.append(za - z[i]) with open( path.join( s.outdir, self.filename(particle, alpha, 'drift_difference_')) + s.outext, 'w') as csvfile: writer = csv.writer(csvfile, delimiter=' ') self.prepareAnalytic(Ek, self.mass(particle)) for i in range(len(tlist)): writer.writerow([tlist[i], xdiff[i], ydiff[i], zdiff[i]])
def run_game(): #初始化游戏并新建一个屏幕对象 pygame.init() #初始化设置 setting = settings.Settings() #初始化屏幕 screen = pygame.display.set_mode( (setting.screen_width, setting.screen_height)) pygame.display.set_caption('Alien Invasion') #创建统计信息、记分牌 stats = game_stats.GameStats(setting) sb = scoreboard.ScoreBoard(setting, screen, stats) #创建开始按钮 play_button = button.Button(setting, screen, 'Play') #创建一艘飞船、一个子弹编组、一个外星人编组 ai_ship = ship.Ship(screen, setting) bullets = Group() aliens = Group() #创建外星人群 game_function.create_fleet(setting, screen, ai_ship, aliens) #开始游戏循环 while True: #监视键盘和鼠标事件 game_function.check_events(setting, screen, ai_ship, bullets, stats, play_button, aliens, sb) #有命的情况下刷新 if stats.game_active: ai_ship.update() game_function.update_bullets(setting, screen, ai_ship, aliens, bullets, stats, sb) game_function.update_aliens(setting, screen, ai_ship, aliens, bullets, stats, sb) #每次循环重新绘制屏幕 game_function.update_screen(setting, screen, ai_ship, aliens, bullets, stats, play_button, sb)
def __init__(self): try: if self.loadingdone: pass except: self.loadingdone = True settings_c = settings.Settings() self.logging = Logging() self.data_location = settings_c.get_setting("data", "location") PATH = os.path.dirname(os.path.abspath(__file__)) self.datafile = PATH + "/../" + self.data_location + "/main_db.pckl" my_file = Path(self.datafile) if not my_file.is_file(): self.logging.write("Creating database", level=1) self.data = { "last_saved": time.time(), "settings": {}, "messages": [] } self.data["settings"]["main_page"] = 0 self.data["settings"]["items_per_page"] = 0 self.data["settings"]["sensors_per_page"] = 0 self.data["settings"]["screen_timeout"] = 1 self.data["settings"]["album_timeout"] = 0 self.data["settings"]["message_timeout"] = 0 self.data["settings"]["mouse"] = 0 self.data["settings"]["screen"] = 0 self.data["settings"]["frame"] = 0 self.data["settings"]["frame_info"] = 0 self.data["settings"]["frame_td"] = 0 self.data["settings"]["frame_display_time"] = 0 self.data["settings"]["toast_timeout"] = 0 self.data["settings"]["clock_type"] = 0 self.data["settings"]["chart_period"] = 0 self.data["settings"]["first_run_messages_flag"] = False self.data["messages"] = [] self.save_datafile() self.data = self.load_datafile()
def __init__(self): self.settings = settings.Settings() self.s_width = self.settings.WIDTH self.s_height = self.settings.HEIGHT self.bg_color = self.settings.bg_color # initalize the screen self.screen = pygame.display.set_mode((self.s_width, self.s_height)) pygame.display.set_caption("Ray Casting Demo") self.screen_rect = self.screen.get_rect() # initialize boundary array self.boundary_list = [] self._create_boundaries() # Initialize boundaries at each wall self.b_top = boundaries.Boundary(self) self.b_right = boundaries.Boundary(self) self.b_left = boundaries.Boundary(self) self.b_bottom = boundaries.Boundary(self) # create rays self.ray = rays.Rays(self)
def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.__views = { 'video': self.__openvideofile, 'webcam': self.__openwebcamcapture, 'analysis': self.__openanalysis } self.__wm_title = args[0] self.__settings = settings.Settings() self.__homeview = views.MainView(self, self.__settings) self.__homeview.grid() self.__videocap = None self.__viewcontroller = controllers.ViewController() self.__videocontroller = None self.__video_open = False self.__data = None self.__datacontroller = None self.__analysisview = None self.__analysis_open = False
def varyingGammaEps(self): g = np.arange(0.0, 0.5, 0.1) e = np.arange(0.0, 0.5, 0.1) s = settings.Settings() for eps in e: for gamma in g: plt.close() self.setupField(alpha=1.0, beta=1.0, gamma=gamma, eps=eps, rho=1.0) self.previewZ() s.outfile = 'tokamakfield_{alpha}_{beta}_{gamma}_{eps}_{rho}'.format( alpha=self.alpha, beta=self.beta, gamma=self.gamma, eps=self.eps, rho=self.rho) s.outext = '.png' plt.savefig(s.outpath())
def run_game(): pygame.init() game_settings = settings.Settings() screen = pygame.display.set_mode((game_settings.screen_width, game_settings.screen_height)) pygame.display.set_caption("Tic-Tac-Toe by Evgeniy Trofimov") # Создание кнопкок play_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height // 2 - 50, "Play") options_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height // 2 + 35, "Options") change_names_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height // 2 + 120, "Change names", font_size=24) menu_exit_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height // 2 + 205, "Exit") names_back_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height - 50, "Back") options_back_button = Button(screen, game_settings.screen_width // 2, game_settings.screen_height - 50, "Back", 100, 38, 32) animated_tic_button = Button(screen, game_settings.screen_width - game_settings.screen_width // 4, game_settings.screen_height // 2, "", 38, 38, 0, game_settings.scoreboard_bg_color) animated_tac_button = Button(screen, game_settings.screen_width - game_settings.screen_width // 4, game_settings.screen_height // 2 + 70, "", 38, 38, 0, game_settings.scoreboard_bg_color ) menu_button = Button(screen, 85, 30, "Menu", 130, 30, 20) reset_score_button = Button(screen, game_settings.screen_width - 85, 30, "Reset score", 130, 30, 20) # Создание полей ввода имён tic_name_pole = EntryPole(game_settings.screen_width // 2, game_settings.screen_height // 4 + 50) tac_name_pole = EntryPole(game_settings.screen_width // 2, game_settings.screen_height // 2 + 50) # Главное меню gf.main_menu(screen, game_settings, play_button, options_button, change_names_button, menu_exit_button, options_back_button, names_back_button, tic_name_pole, tac_name_pole, animated_tic_button, animated_tac_button, menu_button, reset_score_button)
def main(): parser = argparse.ArgumentParser( description='Garfield: An Offensive Framework for attacking DCMS V0.1', usage='%(prog)s [options]') if len(sys.argv) == 1: # parser.add_argument('-h','--help', help='Mandatory Options -t,-p ', required=False) parser.print_help() sys.exit(1) # Specify General Options general = parser.add_argument_group(title='Scan Options Target') general.add_argument('-ip', help='Target to Scan', required=False, metavar='') # general.add_argument('-creds', help='Credentials Format "username:password"', required=False,metavar='') general.add_argument('-port', help='Specify Port', required=False, type=int, metavar='') general.add_argument('-discover', help='Discover consul,etcd,Apache Zookeeper', required=False, metavar='') general.add_argument( '-attack', help='Checks for attacks possible on Consul,Zookeeper & Etcd', required=False, metavar='') args = vars(parser.parse_args()) settings.Settings(args)
def animate(self, alpha, beta, div=4, particle='tr+'): s = settings.Settings() app = mag.Application() field = SmoothField() field.alpha = alpha field.beta = beta field.Bz0 = app.fieldBaseStrength[0] outfile = self.filename(particle, alpha, beta) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) length = len(z) / div for i in xrange(div): start = i * length # if i > 0: # start = (i-1) * length # start=0 end = (i+1) * length if i > 0: plt.plot(z[0:start], y[0:start], 'm-', alpha=0.5, linewidth=0.5, label=self.label(particle)) plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) self.plotField(field, -1.6, 1.6, 0.35, 0.6) # xmin, xmax = plt.xlim() # ymin, ymax = plt.ylim() # self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf()
def StartGame(): # Requirement ID: 9.0.0 """This method initializes the game settings. It also starts and ends the game.""" pygame.init() clock = pygame.time.Clock() settings = set.Settings() pygame.display.set_caption("Zombie Invasion") background = settings.short_grass.convert() background = pygame.transform.scale( background, (settings.screen_width, settings.screen_height)) stats = stat.Stats(settings) display = points.PointsDisplay(settings, stats) shooter = shoot.Shooter(settings) zombies = pygame.sprite.Group() functions.ZombieCollection(settings, shooter, zombies) bullets = pygame.sprite.Group() # Game starts when the play button is pushed. play = button.PlayButton(settings) #Keep playing so long as level is less than or equal to win level while stats.level <= settings.number_of_levels: functions.EventCheck(bullets, play, display, settings, stats, shooter, zombies) if stats.game_active: shooter.update() functions.UpdateObjects(bullets, display, settings, stats, shooter, zombies) #check for win functions.CheckForWin(stats, settings, button, zombies, bullets, shooter) #Update the screen. functions.UpdateScreen(background, bullets, play, display, settings, stats, shooter, zombies) clock.tick(100)
def _run(): try: curSettings = settings.Settings(_getWorkDir() + "/conf.txt") except settings.ReadFailed: logging.warning("settings read failed") return curCollector = collector.Collector() curCollector.addSource(musicbrainz_source.MusicbrainzSource()) curStorage = storage.Storage() try: with curStorage.connect(_getWorkDir() + "/save.dat"): curController = controller.Controller(curStorage, curCollector, curSettings) atClient = at_client.AtClient(curSettings) atClient.setStorage(curStorage) curController.run() except InternalStorageError: logging.error("storage connect failed") raise
def play(): pygame.init() screen_setting = st.Settings() screen = pygame.display.set_mode( (screen_setting.screen_width, screen_setting.screen_height), pygame.RESIZABLE) pygame.display.set_caption(screen_setting.caption) screen, map = gMap.load_map_to_screen('map_2.png') Everything = gc.beginGame(screen, map) #gf.load_bg_sound('AITheme0.mp3') while True: gf.check_event(screen, Everything) screen.blit(map, (0, 0)) Everything.update() Everything.refresh_WeightedMap() Everything.draw(screen) pygame.display.flip()
def __init__(self, *args, **kwargs): Tk.__init__(self, *args, **kwargs) self.settingValues = settings.Settings() self.loadSettings(self.settingValues) self.upLoader = None self.uploadADIF = UploadADIF.UploadServer() self.udpserver = udpServer.Server(self.uploadADIF) self.udpserver.daemon = True self.udpserver.start() self.geometry(str(WIDTH) + "x" + str(HEIGHT)) self.title(appName + " by M0IAX") buttonFrame = Frame(self) buttonFrame.pack() self.show_buttons(buttonFrame, self) labelFrame = Frame(self) labelFrame.pack() aboutLabel = Label(labelFrame, text="M0IAX ADIF Uploader for JS8Call") aboutLabel.grid(row=0, column=0, padx=5, pady=5) #meLabel = Label(labelFrame,text="By M0IAX m0iax.com/findme") #meLabel.grid(row=1,column=0, padx=5, pady=5) if self.upLoader != None: self.configureEQSLButton(self.upLoader.getEQSLEnabled()) self.configureQRZButton(self.upLoader.getQRZEnabled()) if self.uploadADIF != None: self.configureEQSLButton(self.uploadADIF.getEQSLEnabled()) self.configureQRZButton(self.uploadADIF.getQRZEnabled())
def main(): s = settings.Settings() logging.basicConfig(format=s.log_format, level=logging.DEBUG, stream=sys.stdout) if not s.log_level == 'DEBUG': log.debug(f'Changing log level to {s.log_level}') logging.getLogger().setLevel(s.log_level) z = zendesk.ZendeskClient(s.zendesk_company, s.zendesk_username, s.zendesk_password) query = f'type:ticket status<solved updated<{datetime.date.today() - datetime.timedelta(days=366)}' data = z.search(query, sort_by='updated_at', sort_order='asc') succeeded = 0 for result in data.get('results', []): ticket_id = result.get('id') subject = result.get('subject') updated_at = result.get('updated_at')[:10] log.info(f'{ticket_id} / {subject} / updated {updated_at}') params = {'status': 'solved'} for cf in result.get('custom_fields', []): if cf.get('id') == 360000398388: if cf.get('value') is None: params.update({ 'custom_fields': [{ 'id': 360000398388, 'value': 'complete_and_high_quality' }] }) break try: z.update_ticket(ticket_id, params) succeeded += 1 except requests.exceptions.HTTPError as e: log.error(e) log.info(f'Succeeded: {succeeded}')
def __init__(self, args): print( "Server ... starting server and loading model ... please wait until its started ..." ) self.settings = settings.Settings(args) self.load_serverside_handler() frequency_sec = 10.0 if SERVER_VERBOSE > 0: t = Thread(target=self.mem_monitor_deamon, args=([frequency_sec])) t.daemon = True t.start() # hack to distinguish server by hostnames hostname = socket.gethostname() # gpu048.etcetcetc.edu print("server hostname is", hostname) if PRODUCTION: serve(app, host='127.0.0.1', port=5000) else: app.run( threaded=False ) # < with forbiding threaded we still have the same default graph
def run_game(): """初始化游戏创建一个屏幕对象""" print('thread %s is running...' % threading.current_thread().name) pygame.init() ai_setting = settings.Settings() screen = pygame.display.set_mode( (ai_setting.screen_width, ai_setting.screen_height)) pygame.display.set_caption("Alien Invasion") ship = Ship(ai_setting.ship_speed_factor, screen) #创建存储子弹的编组 bullets = Group() #创建外星人群 aliens = Group() gf.create_fleet(ai_setting, screen, ship, aliens) #创建统计信息 stats = GameStats(ai_setting) #创建play按钮 play_button = Button(ai_setting, screen, "play") #创建统计游戏得分的实例 sb = Scoreboard(ai_setting, screen, stats) while (True): gf.check_events(ai_setting, screen, ship, aliens, bullets, stats, play_button, sb) #当前游戏处于激活状态 if stats.game_active: gf.update_ship(ship) gf.update_bullets(ai_setting, screen, ship, bullets, aliens, stats, sb) gf.update_aliens(ai_setting, stats, screen, ship, aliens, bullets, sb) gf.update_screen(ai_setting, screen, ship, bullets, aliens, stats, play_button, sb)