이봐 난 파이 게임에 약간의 게임 프로젝트에서 일하고 있어요,하지만 매번 나는 그가 내 스프라이트 사용에 도달 할 때 나는 오류가 내 코드를 실행하려고 여기파이 게임 : 스프라이트
class Sprite:
def _init_(self, xposition, yposition, name):
self.x = xposition
self.y = yposition
self.bitmap = image.load(name)
self.bitmap.set_colorkey ((0,0,0))
def set_position(self, xposition, yposition):
self.x = xposition
self.y = yposition
def render(self):
screen.blit(self.bitmap, (self.x, self.y))
과 내가 그것을 호출하는 방법입니다
hero = Sprite(20,400, 'spaceship.bmp')
herobullet = Sprite(0,480, 'bulete.bmp')
enemiebullet = Sprite(0,480, 'bulete.bmp')
업데이트 여기
commad 라인에서 오는 오류 메시지가
Visual Studio \ 2.0 \ visualstudio_py_debugger.py에 대한 C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ Extensions \ Microsoft \ Python 도구 : 720 : 유니 코드 경고 : 유니 코드 비교가 두 인수를 유니 코드로 변환하지 못했습니다. 파일 이름 == frame.f_code.co_filename 또는 (바운드 및 breakpoint_path_match (파일 이름, frame.f_code.co_filename)) : C : \ Program Files (Microsoft) Visual Studio 12.0 \ Common7 \ IDE 인 경우 불완전한 것으로 해석합니다 ( ). \ Extensions \ Microsoft \ Python Tools for Visual Studio \ 2.0 \ visualstudio_py_util.py : 265 : RuntimeWarning : surfarray 사용 : numpy 또는 Numer라는 모듈이 없음 (ImportError : numpy 또는 Numeric이라는 모듈이 없음) obj_repr = repr (obj) C : \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ Extensions \ Microsoft \ Python Tools for Visual Studio \ 2.0 \ visualstudio _py_util.py:265 : RuntimeWarning : sndarray : numpy 또는 Numeric 모듈을 찾지 못했습니다. (ImportError : numpy 또는 Numeric 모듈이 없습니다.) obj_repr = repr (obj) '[6344] python.exe'프로그램이 종료되었습니다. 코드 -1073741510 (0xc000013a). 우리가 어디에서 검색하는 방법 : 그래서 하나의 가능한 오류가
self.bitmap = image.load(name)
당신이 만약이 될 수 알 수 있도록 여기
는 모두의from pygame import *
import random
from Space_invader import *
#create the sprite for both enemy and hero
class Sprite:
def _init_(self, xposition, yposition, name):
self.x = xposition
self.y = yposition
self.bitmap = image.load(name)
self.bitmap.set_colorkey ((0,0,0))
def set_position(self, xposition, yposition):
self.x = xposition
self.y = yposition
def render(self):
screen.blit(self.bitmap, (self.x, self.y))
# colision detection betwee two 32*32 sprite
def Intersect(o1_x, o1_y, o2_x, o2_y):
if (o1_x > o2_x - 32) and (o1_x < o2_x + 32) and (o1_y > o2_y - 32) and (o1_y < o2_y + 32):
return 1
else:
return 0
#initialise pygame
init()
screen = display.set_mode((640,480))
key.set_repeat(1,1) #make sure you can press the same key more then one and that there is a delay between each action
display.set_caption('UON Invader') #set windows name
background = image.load('background.png') #load background picture
hero = Sprite(20,400, 'spaceship.bmp')
herobullet = Sprite(0,480, 'bulete.bmp')
enemiebullet = Sprite(0,480, 'bulete.bmp')
오류가 발생했습니다. – CoryKramer
정확한 오류를 알려 주실 수 있습니까? – evamvid