def __init__(self, center_x, center_y, animation_images, saved_params=None): super().__init__(center_x, center_y, animation_images) self._max_health = self._max_mana = self._max_stamina = 100 self._speed_changing = 3 self._amount_damage = random.randint(140, 200) self._passive_regeneration = 0.1 self._regeneration_interval = 10 self._last_attack_time = 250 self._animation_interval = 150 self._experience_up_level = 1000 * pow(1.1, self._level) self._selected_attack = GameEnums.AttackTypes.FIREBALL.value self._inventory = Inventory.Inventory() self._health_bar = Bar.Bar(Constants.GAME_WINDOW_WIDTH // 2 - 250, Constants.GAME_WINDOW_HEIGHT - 96, 'resources/images/bars/health_bar.png') self._mana_bar = Bar.Bar(Constants.GAME_WINDOW_WIDTH // 2 + 155, Constants.GAME_WINDOW_HEIGHT - 96, 'resources/images/bars/mana_bar.png') if saved_params is None: self._level = 1 self._current_experience = 0 self._current_health = 100 self._current_stamina = self._max_stamina self._current_mana = self._max_mana else: self._level = saved_params['level'] self._current_experience = saved_params['current_experience'] self._current_health = saved_params['current_health'] self._current_stamina = saved_params['current_stamina'] self._current_mana = saved_params['current_mana']
def reset(self): self.bars.clear() y0 = -self.bar_height for i in range(self.number_of_bars): self.bars.append( Bar(self.game, Vector2D(0, y0 - i * (self.offset + self.bar_height))))
def setUp(self): self.c = Character("bob") self.bar = Bar("Test") self.bar.add_box(Box(1)) self.bar.add_box(Box(2)) self.bar.add_box(Box(3)) self.bar.add_box(Box(4)) self.c.add_bar(self.bar)
def __init__(self, name, refresh_rate=3): self.name = name self.bars = {} # address bars by name self.aspects = AspectContainer() self.skills = SkillContainer() self.fate = 0 self.refresh_rate = refresh_rate self.consequence_bar = Bar("consequence") self.consequences = []
def bar_default(name): """ Returns a bar of size 1, 2 :param name: the name of the bar :return: """ b = Bar(name) b.add_box(Box(1)) b.add_box(Box(2)) return b
def bar_consequence(name): """ Returns a bar of size 2, 4, 6 :param name: the name of the bar :return: """ b = Bar(name) b.add_box(Box(2)) b.add_box(Box(4)) b.add_box(Box(6)) return b
def sethero(self): i = None for i in self.planets: break self.player = Player((i.rect.x, i.rect.y - i.radius)) if loadlatest == True and self.s.dataexist(): t = self.s.loadrecent() self.player.pos = np.array([t[1], t[2]]) self.player.vel = np.array([t[3], t[4]]) self.player.angle = t[5] self.player.accel = np.array([t[6], t[7]]) self.hero.add(self.player) self.fuelbar = Bar()
def insertEmptyBar(self,n): i=n bar = Bar.Bar() while(i>1): rownum = self.dailyBar.shape[0]-1 bar.strtime=' ' bar.utc_time=self.dailyBar.ix[rownum]['utcdatetime']+60 bar.open=0 bar.close=0 bar.high=self.dailyBar.ix[rownum]['high'] bar.low=self.dailyBar.ix[rownum]['low'] bar.position=self.dailyBar.ix[rownum]['position'] self.update_dailyBar(bar) if(datetime.datetime.fromtimestamp(bar.utc_time).minute% self.K_min==0): self.update_dailyBarMin(bar) pass i-=1 pass
def get_bars(songs_data): bars = [] for song_data in songs_data: seg_starts = song_data.seg_starts bar_starts = song_data.bar_starts pitches = song_data.seg_pitches # Because of how the song data is being collected, these two # don't match up, even though they should pitches_and_segs = min(len(pitches), len(seg_starts)) - 1 # The bars starts don't match exactly with the pitch starts, # hence this mess for i in xrange(pitches_and_segs): # The if should be true for bar_starts[len(bars)], but this # is to make sure. for j in range(len(bars), len(bar_starts)): if seg_starts[i] < bar_starts[j] < seg_starts[i+1]: bars.append(str(Bar.Bar(SongData.get_pitch(pitches[i])))) return bars
import os import sys import string sys.path.insert(0, '../lib/') from Parser import * from Polygon import * from Scatter import * from Pie import * from Bar import * if __name__ == '__main__': test_pie = ParsePie("../json/pie.json") test_bar = ParseBar("../json/bar.json") test_scat = ParseScatter("../json/scatter.json") dict_pie = test_pie.process_data() dict_bar = test_bar.process_data() dict_scat = test_scat.process_data() pie = Pie(dict_pie, "Movies") bar = Bar(dict_bar) scat = Scatter(dict_scat)
def main(): parser = argparse.ArgumentParser() parser.add_argument('source_path', help="Path to the video or audio file to subtitle", nargs='?') parser.add_argument('-C', '--concurrency', help="Number of concurrent API requests to make", type=int, default=10) parser.add_argument('-o', '--output', help="Output path for subtitles (by default, subtitles are saved in \ the same directory and name as the source path)") parser.add_argument('-F', '--format', help="Destination subtitle format", default="srt") parser.add_argument('-S', '--src-language', help="Language spoken in source file", default="en") parser.add_argument('-D', '--dst-language', help="Desired language for the subtitles", default="en") parser.add_argument('-K', '--api-key', help="The Google Translate API key to be used. (Required for subtitle translation)") parser.add_argument('--list-formats', help="List all available subtitle formats", action='store_true') parser.add_argument('--list-languages', help="List all available source/destination languages", action='store_true') args = parser.parse_args() ifargs.list_formats: print("List of formats:") forsubtitle_format in FORMATTERS.keys(): print("{format}".format(format=subtitle_format)) return 0 ifargs.list_languages: print("List of all languages:") for code, language in sorted(LANGUAGE_CODES.items()): print("{code}\t{language}".format(code=code, language=language)) return 0 ifargs.format not in FORMATTERS.keys(): print("Subtitle format not supported. Run with --list-formats to see all supported formats.") return 1 ifargs.src_language not in LANGUAGE_CODES.keys(): print("Source language not supported. Run with --list-languages to see all supported languages.") return 1 ifargs.dst_language not in LANGUAGE_CODES.keys(): print( "Destination language not supported. Run with --list-languages to see all supported languages.") return 1 if not args.source_path: print("Error: You need to specify a source path.") return 1 audio_filename, audio_rate = extract_audio(args.source_path) regions = find_speech_regions(audio_filename) pool = multiprocessing.Pool(args.concurrency) converter = FLACConverter(source_path=audio_filename) recognizer = SpeechRecognizer(language=args.src_language, rate=audio_rate, api_key=GOOGLE_SPEECH_API_KEY) transcripts = [] if regions: try: widgets = ["Converting speech regions to FLAC files: ", Percentage(), ' ', Bar(), ' ', ETA()] pbar = ProgressBar(widgets=widgets, maxval=len(regions)).start() extracted_regions = [] fori, extracted_region in enumerate(pool.imap(converter, regions)): extracted_regions.append(extracted_region) pbar.update(i) pbar.finish() widgets = ["Performing speech recognition: ", Percentage(), ' ', Bar(), ' ', ETA()] pbar = ProgressBar(widgets=widgets, maxval=len(regions)).start() fori, transcript in enumerate(pool.imap(recognizer, extracted_regions)): transcripts.append(transcript) pbar.update(i) pbar.finish() if not is_same_language(args.src_language, args.dst_language): ifargs.api_key: google_translate_api_key = args.api_key translator = Translator(args.dst_language, google_translate_api_key, dst=args.dst_language, src=args.src_language) prompt = "Translating from {0} to {1}: ".format(args.src_language, args.dst_language) widgets = [prompt, Percentage(), ' ', Bar(), ' ', ETA()] pbar = ProgressBar(widgets=widgets, maxval=len(regions)).start() translated_transcripts = [] fori, transcript in enumerate(pool.imap(translator, transcripts)): translated_transcripts.append(transcript) pbar.update(i) pbar.finish() transcripts = translated_transcripts else: print ("Error: Subtitle translation requires specified Google Translate API key. \ See --help for further information.") return 1 exceptKeyboardInterrupt: pbar.finish() pool.terminate() pool.join() print ("Cancelling transcription") return 1 timed_subtitles = [(r, t) for r, t in zip(regions, transcripts) if t] formatter = FORMATTERS.get(args.format) formatted_subtitles = formatter(timed_subtitles) dest = args.output if not dest: base, ext = os.path.splitext(args.source_path) dest = "{base}.{format}".format(base=base, format=args.format) with open(dest, 'wb') as f: f.write(formatted_subtitles.encode("utf-8")) print ("Subtitles file created at {}".format(dest)) os.remove(audio_filename) return 0 if __name__ == '__main sys.exit(main())
def __bar(self): Player.unlock_c = 1 self.__bg.destroy() Bar.Bar()
clock = pygame.time.Clock() LOGO_IMAGE = pygame.image.load(os.path.join("logo.png")) MAP_WIDTH = 500 MAP_HEIGHT = 500 GAME_AREA = (30, 30, 30 + MAP_WIDTH, 30 + MAP_HEIGHT) #게임 데이터들 FAST_FPS = 50 SLOW_FPS = 10 FPS = FAST_FPS BAR_WIDTH = 200 BAR_HEIGHT = 20 BAR_MOVE_WIDTH = 20 BALL_MOVE_SPEED = 4 game = True bar = Bar.Bar(((MAP_WIDTH - BAR_WIDTH) / 2, MAP_HEIGHT - BAR_HEIGHT)) barCoord = [(MAP_WIDTH - BAR_WIDTH) / 2, MAP_HEIGHT - BAR_HEIGHT] boundary = False #끝에 닿았는지 RANDOM_VECTOR_SPEED = 90 randomVectorCount = 1 vectorDirection = [-2, 1] ball = Ball((30, 30), 10) drawRainbow = drawRainbow(FPS) # to create bricks and brickList brickList = {} #초기 bricks 생성
chord_list += [chord_name_em, chord_name_a, chord_name_d, chord_name_d] tempo = 200.0 midi = pretty_midi.PrettyMIDI(initial_tempo=tempo) music_program = pretty_midi.instrument_name_to_program('Vibraphone') chord_program = pretty_midi.instrument_name_to_program('Marimba') music_part = pretty_midi.Instrument(program=music_program) chord_part = pretty_midi.Instrument(program=chord_program) ## 本番 # now_pos: 16分音符何個分の位置にいるか now_pos = 0 for chord_s in chord_list: chord = Chord.Chord(chord_s) # 主旋律 bar = Bar.Bar(chord, tempo, now_pos) nodes = bar.Nodes for node in nodes: note = node.note music_part.notes.append(note) # コードの貼り付け for pitch_int in chord.pitch_ints: node = Node.Node(16, pitch_int, now_pos, tempo) note = node.note chord_part.notes.append(note) # 共通 now_pos += 16 # コードだけ # for chord_s in chord_list: # chord = Chord.Chord(chord_s)
def set(canvas,g): axes = adxl345.getAxes(True) g.setGforce(axes['x'],axes['y']) canvas.after(5,set,canvas,g) None root = Tk() canvas = Canvas(root,width=winWidth,height=winHeight,bg="white") canvas.pack() rpm = Rpm(canvas,winWidth/2,winHeight/4,winWidth/1.25,winHeight/4,50,"yellow","yellow",20,140,0,10000) speed = Text(canvas,winWidth/2,winHeight/4,"Helvetica",speedFontSize,"bold italic","black","137") mileage = Text(canvas,winWidth/2,(winHeight/10)*3,"Helvetica",10,"bold ","black","162.372 KM") clutch=Bar(canvas,winWidth-92,winHeight,30,-60,"blue") brake=Bar(canvas,winWidth-61,winHeight,30,-30,"red") throttle=Bar(canvas,winWidth-30,winHeight,30,-100,"green") temp1 = Circle(canvas,(winWidth/4)*1,(winHeight/2)*1,100,25,240,300,20,100,"#28cfbc",circleFontSize,"OIL T.") temp2 = Circle(canvas,(winWidth/4)*2,(winHeight/2)*1,100,25,240,300,20,100,"#28cfbc",circleFontSize,"OIL P.") temp3 = Circle(canvas,(winWidth/4)*3,(winHeight/2)*1,100,25,240,300,20,100,"#28cfbc",circleFontSize,"H2O T.") temp4 = Circle(canvas,(winWidth/4)*1,(winHeight/4)*3,100,25,240,300,20,100,"#28cfbc",circleFontSize,"H2O T.2") temp5 = Circle(canvas,(winWidth/4)*2,(winHeight/4)*3,100,25,240,300,20,100,"#28cfbc",circleFontSize,"IAT") #temp6 = Circle(canvas,(winWidth/4)*3,(winHeight/4)*3,100,25,240,300,20,100,"#28cfbc",circleFontSize,"BAT") arrowLeft=Arrow(canvas,(winWidth/3)*1,winHeight/4,0.15,"green","left") arrowRight=Arrow(canvas,(winWidth/3)*2,winHeight/4,0.15,"green","right") g = Gforce(canvas,(winWidth/4)*3,(winHeight/4)*3,125,2,1,"gray",4,"red")
LOGO_IMAGE = pygame.image.load(os.path.join("logo.png")) # 로고 이미지 불러오기 MAP_WIDTH = 500 #게임 플레이할 공간의 가로 길이 MAP_HEIGHT = 500 #게임 플레이할 공간의 세로 길이 GAME_AREA = (30, 30, 30 + MAP_WIDTH, 30 + MAP_HEIGHT ) # 게임 플레이할 공간과 실행창 사이 간격? (왼쪽 사이 간격, 위쪽 사이 간격, ...?) #게임 데이터들 FAST_FPS = 50 #빠른 FPS SLOW_FPS = 10 #느린 FPS FPS = FAST_FPS #빠른 FPS로 기본 설정 BAR_WIDTH = 100 #바 가로 길이 BAR_HEIGHT = 20 #바 세로 길이 BAR_MOVE_WIDTH = 20 BALL_MOVE_SPEED = 4 game = True bar = Bar.Bar(((MAP_WIDTH - BAR_WIDTH) / 2, MAP_HEIGHT - BAR_HEIGHT)) #게임 초기 실행시 바 기본위치 (가로, 세로) barCoord = [(MAP_WIDTH - BAR_WIDTH) / 2, MAP_HEIGHT - BAR_HEIGHT] boundary = False #끝에 닿았는지 확인 currentLife = 10 RANDOM_VECTOR_SPEED = 90 #??? randomVectorCount = 1 #??? vectorDirection = [-2, 1] #공 벡터 방향 ball = Ball((30, 30), 10) drawRainbow = drawRainbow(FPS) # to create bricks and brickList brickList = {}
def __add_bar_(self): last_bar = self.bars[-1] position = Vector2D( 0, last_bar.position.y - (self.offset + self.bar_height)) self.bars.append(Bar(self.game, position))
from DirectorioDeBares import * from Bar import * from Caracteristica import * from Calificacion import * from RegistroDeCalificaciones import * from Cartografo import * wifi = Caracteristica("Wi-Fi") aircon = Caracteristica("Aire Acondicionado") precios = Caracteristica("Precios") directorio = DirectorioDeBares() cartografo = Cartografo() bar1 = Bar("Tienda del cafe", "Santa Fe y Callao", [wifi]) bar2 = Bar("Cafe Martinez", "Av. Pueyrredon y Cordoba", [wifi, aircon, precios]) bar3 = Bar("Starbucks", "Las Heras y Uriburu", [aircon, precios, Caracteristica("enchufes")]) bar4 = Bar("Tips", "Las Heras y Av. Pueyrredon", [wifi]) bar5 = Bar("Muu lecheria", "Costa Rica y Armenia", []) bar6 = Bar("La biela", "Junin y Guido", [wifi]) bar7 = Bar("Pani", "Junin y Vicente Lopez", [wifi, precios]) bar8 = Bar("Milli", "Av. Pueyrredon y French", [wifi, aircon, precios]) directorio.agregar(bar1) directorio.agregar(bar2) directorio.agregar(bar3) directorio.agregar(bar4) directorio.agregar(bar5)
##### crear usuarios print '\nCreando usuarios\n' user1 = Usuario("Leandro") user2 = Usuario("Juani") user3 = Usuario("Axel") user4 = Usuario("Andy") user5 = Usuario("Petr") user6 = Usuario("Axel") print '\nCreando bares\n' #### crear bares bar1 = Bar("Super Bar", (1000, 1000), True) bar2 = Bar("Nuevo Bar", (3, 1), True) bar3 = Bar("Bar Cool", (1, 3), False) bar4 = Bar("Nuevo Bar", (-1000, -999), True) bar5 = Bar("Nuevo Bar 3", (10, 10), True) print '\nProbando registros bares y usuarios\n' #### probando registros regBar = RegistrarBar() regUser = RegistrarUsuario() RegistroBares = [] RegistroUsuarios = [] regBar.agregarBar(bar1, RegistroBares)