#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http 제목pygame 질문을 드려도 될까요?2019-05-19 16:10작성자pygamehttps://github.com/EricsonWillians/Pyfader surface에 페이드 인, 아웃 효과를 넣고 싶어서 pyfader라는 라이브러리르 다운 받았는데예제 파일을 재생하면 pyfader.py 에서 syntax 오류가 있다고 나옵니다.근데 코드가 너무 생소한 형식(try, except나 raise, pass 같은..)이라 왜 안 되는 건지 잘 모르겠습니다. ㅠㅠ아래가 pyfader.py 입니다"""====================================================================Pyfader - v1.0Copyright (C) <2014> <Ericson Willians.>This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.====================================================================Written by Ericson Willians, a brazilian composer and programmer.CONTACT: ericsonwrp@gmail.comAS A COMPOSER: https://soundcloud.com/r-p-ericson-williansYOUTUBE CHANNEL: http://www.youtube.com/user/poisonewein===================================================================="""import osimport pygameclass IFader(): """ The Image Fader. It creates a Surface object given a raw image file. It provides a method for drawing the Surface, whether it fades or not. """ def __init__(self,path,name,size=None,bgColor=(0,0,0),initAlpha=0): self.sur = self.loadImage(path,name) if size is not None: # Where None is 'default image size'. try: self.sur = pygame.transform.scale(self.sur,size) except: print "A tuple with two indexes with integers is an acceptable size. '(n,n)'" elif size is None: pass self.bgColor = bgColor self.initAlpha = initAlpha self.sur.set_alpha(self.initAlpha) def loadImage(self,path,name,colorkey=None): fullname = os.path.join(path,name) try: i = pygame.image.load(fullname) except error, message: print "Cannot load image:", name raise SystemExit, message if ".png" not in name: i = i.convert() else: i = pygame.Surface.convert_alpha(i) if colorkey is not None: if colorkey is -1: colorkey = i.get_at((0,0)) i.set_colorkey(colorkey,pygame.RLEACCEL) return i def fadeIn(self,fSpeed=0.1): self.initAlpha += fSpeed def fadeOut(self,fSpeed=0.1): self.initAlpha -= fSpeed def draw(self,destSur,pos=(0,0)): # Where 'destSur' means 'Destination Surface'. destSur.fill(self.bgColor) destSur.blit(self.sur,(pos[0],pos[1])) self.sur.set_alpha(self.initAlpha)class GSFader(): """ The General Surface Fader. It requires an external Surface object. It provides a method for drawing the Surface, whether it fades or not. """ def __init__(self,surface,bgColor=(0,0,0),initAlpha=0): self.sur = surface self.bgColor = bgColor self.initAlpha = initAlpha def fadeIn(self,fSpeed=0.1): self.initAlpha += fSpeed def fadeOut(self,fSpeed=0.1): self.initAlpha -= fSpeed def draw(self,destSur,pos=(0,0)): destSur.fill(self.bgColor) destSur.blit(self.sur,(pos[0],pos[1])) self.sur.set_alpha(self.initAlpha) 목록수정삭제답변글쓰기 댓글 [2] 댓글작성자(*)비밀번호(*)내용(*) 댓글 등록 더보기이전github usage 질문ㅇㅇ2019-05-19다음naver api - datalab httperror 400: bad requestlululala2019-05-19 Powered by MangBoard | 워드프레스 쇼핑몰 망보드