본문 바로가기

개발 기록/자동 포스팅 프로그램

(25)
Configuration 정리 from design_sets import colorsimport randomimport math#---------------------기본 초기화--------------------------------# 화면 및 게임 설정 상수GAME_WIDTH = 1080GAME_HEIGHT = 1920BG_COLOR = colors['black']MONO_BG_COLOR = colors['black']# Border 설정 상수CENTER = (550, 960)RADIUS = 500THICKNESS = 10#Border 색 설정INNER_COLOR = colors['black'] # 내부 색상OUTER_COLOR = colors['white'] # 외부 색상MONO_INNER_COLOR = colors['bla..
uploader 코드 정리 import osimport picklefrom google_auth_oauthlib.flow import InstalledAppFlowfrom googleapiclient.discovery import buildfrom googleapiclient.http import MediaFileUploadfrom googleapiclient.errors import HttpErrorfrom google.auth.exceptions import RefreshErrorfrom google.auth.transport.requests import Request# YouTube API를 사용하기 위한 스코프 지정SCOPES = ['https://www.googleapis.com/auth/youtube.upload']de..
프로그램 로직 중간 기록 from pydub import AudioSegmentimport os# ffmpeg 환경 설정ffmpeg_path = r'C:\ffmpeg-2024-04-10-git-0e4dfa4709-full_build\bin' # 실제 ffmpeg 설치 경로로 변경하세요.os.environ['PATH'] += os.pathsep + ffmpeg_pathdef add_collision_sounds_based_on_type(collision_times, collision_sound_path, output_path, audio_type, clip_length_ms=2500): """ 주어진 시간에 맞춰 뮤직 또는 효과음을 삽입하여 무음 배경 오디오 파일을 생성하는 함수. Args: - collis..
배경음 관리 기법 해결 방안 모색 class SoundGimmick(GimmickStrategy): def __init__(self, sound_file): self.sound_file = sound_file self.audio = AudioSegment.from_file(self.sound_file) self.playback_object = None self.current_position = 0 # 현재 재생 위치 (밀리초 단위) self.is_playing = False self.is_paused = False self.lock = threading.Lock() def play(self): with self.lock: if not self.is_playing or self.is_paused: self.is_playing = True ..
기믹 추가 내용 정리 다시 몇 가지 기믹을 추가하는데 성공하였다. 아래는 그러한 기믹들의 내용과 구현 방법에 대한 정리이다. class ConnectGimmick(GimmickStrategy): def __init__(self): self.collision_point_list = [] def apply(self, ball, border, game): for point in self.collision_point_list: pygame.draw.line(game.screen, ball.color, (int(point.x), int(point.y)), ball.position, 2) def add(self, ball, border, game): direction = ball.position - border.center distan..
기믹 추가 내용 정리 저번에 만든 시스템을 기반으로 몇 가지 기믹을 추가하는데 성공하였다. 아래는 그러한 기믹들의 내용과 구현 방법에 대한 정리이다. def lerp_color(start_color, end_color, t): """ 선형 보간을 사용하여 두 색상 사이의 중간 색상을 계산합니다. :param start_color: 시작 색상 (R, G, B) :param end_color: 끝 색상 (R, G, B) :param t: 보간 비율 (0.0 ~ 1.0) :return: 보간된 중간 색상 (R, G, B) """ r = start_color[0] + (end_color[0] - start_color[0]) * t g = start_color[1] + (end_color[1] - start_color[1]) * t ..
설정 파일을 통한 랜덤한 시뮬레이션 제작 환경 구축 성공! 저번 포스팅에서부터 많은 고민과 개선이 있었다. 가장 큰 부분은 어떻게 해야 하나의 코드로 다양한 시뮬레이션을 실행할 수 있을가이다. 사실, 클래스를 통해 만들었으므로 이를 개별적으로 처리하여 실행한다면 다양한 경우의 환경을 구축하는 것 자체는 어렵지 않다. 그렇다면 뭐가 문제인가 하면 내가 추구한느 것은 완전한 자동화라는 것이다. 여러 시뮬레이션의 상황에 대한 것 중 하나를 자동으로 골라 영상을 위한 시뮬레이션이 진행되어야 개발 목표에 맞는 결과물이라 볼 수 있다. 이를 위해 딕셔너리를 활용하였다. 아래는 이를 모아놓은 game_configurations 파일이다. 임포트 된 design_sets의 경우 색상 이름을 딕셔너리로 저장해놓은 파일이다. from design_sets import colors..
클래스 생성을 통한 기믹 관리 https://www.youtube.com/shorts/FpdBqbW_jBo 제작 목표 Bounce_ball의 기능을 클래스로 변경하며 일부 기능 구현에도 성공하였다. 커밋이야 깃 허브에 꾸준히 하지만 경과 정리를 블로그에 해보겠다. 가장 큰 변화는 대부분의 기능을 클래스로 옮긴 것이다. 아래는 공 클래스다. class Ball: def __init__(self, position, speed, radius, color, growth, energy_loss): self.position = pygame.math.Vector2(position) self.speed = pygame.math.Vector2(speed) self.radius = radius self.color = color self.growth =..