분류 전체보기 (14) 썸네일형 리스트형 [pygame] 버튼, text 줄넘김 구현 버튼을 클릭하려면 마우스가 버튼 위에 있는지 , 마우스를 클릭 한지 확인해야 한다 버튼: class Button: def __init__(self, position): self.default = pygame.Surface((50, 50), pygame.SRCALPHA) self.default.fill((0, 0, 0)) self.clicked = pygame.Surface((50, 50), pygame.SRCALPHA) self.clicked.fill((255, 255, 255)) self.image = self.default self.rect = self.image.get_rect(center=position) self.position = position self.click_event = lambda:.. [pygame_phyics] 기본 오브젝트 예제 & 설명 [import 하지 않고 내부적으로 사용되는 것] Component: 기본 함수만 선언해놓음, 용도: 없는 함수 실행하는 오류를 막기위해서 Joint: 물리 새계에서 연결하는 함수를 정의해놓음 Object(Component): Manger.scene 에 등록하고 삭제하는 코드를 추가함 씬에 등록할수 있는 가장 기초적인 클래스 Object.instantiate(등록할 객체) 이렇게 등록하고 등록할 객체.delete() 로 삭제합니다 삭제할땐 이름이랑 태그가 None 이 되고 씬에서 삭제됩니다 Phyics(GameObject, Joint): on_colision_enter(self, collision) 으로 충돌할때 실행됩니다 UI(GameObject): ui 에서 필요한 좌표랑 각도를 생성 [import .. pygame 입력 필드 만들기 pygame.key.start_text_input() 일단 이벤트로 받는데 그렇기 위해서는 게임 시작때 이것을 실행해야한다 입력 필드 예제: class InputField: def __init__(self, size) -> None: self.image = pygame.Surface(size, pygame.SRCALPHA) self.image.fill((0, 0, 0, 255)) self.font = pygame.font.SysFont("malgungothic", size[1]) self.text = "" # 글자 원본 self.edit_pos = 0 # 수정하는 위치 / 깜박꺼리는 커서 self.text_edit = False self.text_editing = "" # 한국어처럼 글자 편집하는 글자 .. [pygame_phyics] save 소개 & 사용시 GameObject 주의사항 ** 현재 save 함수를 두번 이상 사용시 Vector 클래스가 저장되지 않는 버그가 있습니다. ** save 사용시 불러와야합니다 from pygame_phyics.save import save 매개 변수는 layers, path, 키워드 >> 저장할 변수 사용 예: save(Manger.scene.layers, './images/save.json', score=Manger.score) layers 는 저장할 맵에 layers, path 는 파일을 저장할 경로, 키워드는 매니저 클래스에 저장할 이름=변수 이런식으로 작성하시면 됩니다. 하지만 매니저 클래스에서 이미 사용중인 classes, screen, scene, WIDTH, HEIGHT 들은 사용하시면 안됩니다 주의사항: save 함수를 사용을 하.. pygame phyics 업데이트 변경사항: 맵 함수 생성방식이 변경됨 @game.phyics_world("example/example.json") def example(): rect : DynamicObject= Manger.scene.get_objects("hello")[0] circle = Manger.scene.get_objects("ello")[0] text = Manger.scene.get_objects("eello")[0] inputfield : InputField = Manger.scene.get_objects("eeldlo")[0] def start(cls): text.text = 'hello\nworld!\n 한국어' rect.create_joint(4.0, 0.5, circle) def inputd(text): pri.. [pygame_phyics] 라이브러리 소개 라이브러리 업데이트 >>> https://fireing123.tistory.com/entry/pygame-phyics-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8 pygame phyics 업데이트 변경사항: 맵 함수 생성방식이 변경됨 @game.phyics_world("example/example.json") def example(): rect : DynamicObject= Manger.scene.get_objects("hello")[0] circle = Manger.scene.get_objects("ello")[0] text = Manger.scene.get_objects("eello")[0] fireing123.tistory.com 깃허브 주소 : https://github.co.. 이전 1 2 다음