2012-06-26 26 views
1

我正在爲我正在製作的遊戲製作關卡編輯器。我已經設置好了,這樣你就可以將一張圖片放入一個文件夾中,並將它從90x90像素塊分割爲9個可用於編輯器的30x30像素塊。這使得30×30塊中的代碼如下所示:我已經做了一個Pygame程序,但是當精靈重疊時,它有一些白色輪廓

one = Image.new('RGBA',(30,30),(255,255,255,0)) 
    two = Image.new('RGBA',(30,30),(255,255,255,0)) 
    three = Image.new('RGBA',(30,30),(255,255,2550,0)) 
    four = Image.new('RGBA',(30,30),(255,255,255,0)) 
    five = Image.new('RGBA',(30,30),(255,255,255,0)) 
    six = Image.new('RGBA',(30,30),(255,255,2550,0)) 
    seven = Image.new('RGBA',(30,30),(255,255,2550,0)) 
    eight = Image.new('RGBA',(30,30),(255,255,255,0)) 
    nine = Image.new('RGBA',(30,30),(255,255,255,0)) 

    for y in range(1,iy): 
     print ((y/9)*10),"%" 
     for x in range(1,ix): 
      pixel = im.getpixel((x,y)) 
      if y<30: 
       if x<30: 
        one.putpixel((x,y),pixel) 
       elif x<60: 
        four.putpixel((x-30,y),pixel) 
       else: 
        seven.putpixel((x-60,y),pixel) 
      elif y <60: 
       if x <30: 
        two.putpixel((x,y-30),pixel) 
       elif x <60: 
        five.putpixel((x-30,y-30),pixel) 
       else: 
        eight.putpixel((x-60,y-30),pixel) 
      else: 
       if x < 30: 
        three.putpixel((x,y-60),pixel) 
       elif x < 60: 
        six.putpixel((x-30,y-60),pixel) 
       else: 
        nine.putpixel((x-60,y-60),pixel) 
    add = [im,one,two,three,four,five,six,seven,eight,nine] 
    bdict[s]= add 
    cd = os.getcwd()+'\\'+s +'\\' 
    one.save(cd + s +'one.png') 
    two.save(cd+s+'two.png') 
    three.save(cd+s+'three.png') 
    four.save(cd+s+'four.png') 
    five.save(cd+s+'five.png') 
    six.save(cd+s+'six.png') 
    seven.save(cd+s+'seven.png') 
    eight.save(cd+s+'eight.png') 
    nine.save(cd+s+'nine.png') 
    im.save(cd + fol) 
    im = os.getcwd()+'\\'+fol 
    one = os.getcwd()+'\\'+s+'one.png' 
    two =os.getcwd()+'\\'+s+'two.png' 
    three =os.getcwd()+'\\'+s+'three.png' 
    four = os.getcwd()+'\\'+s+'four.png' 
    five =os.getcwd()+'\\'+s+'five.png' 
    six =os.getcwd()+'\\'+s+'six.png' 
    seven =os.getcwd()+'\\'+s+'seven.png' 
    eight =os.getcwd()+'\\'+s+'eight.png' 
    nine =os.getcwd()+'\\'+s+'nine.png' 
    add = [im,one,two,three,four,five,six,seven,eight,nine]   
    bdict[s]= add 
    maxes[0]+=1 

當兩個區塊重疊,他們有這個奇怪的白色欄只顯示了周圍的左上角和右上角塊和底部的左側和右側塊。這看起來是這樣的: overlap error

其中代碼加載精靈,這裏可能有錯誤是唯一的其他地方: 理由是含有不同的矩形,同時gsprites是包含在不同的精靈的數組的數組它們由Pygame加載的格式。

for number in range(0,len(grounds)): 
    cr = grounds[number] 
    cr.left += xscroll 
    cr.top += yscroll 
    pygame.draw.rect(windowsurface,clear,cr) 
    change = pygame.transform.scale(gsprites[number],(30,30)) 
    windowsurface.blit(gsprites[number],cr) 
    cr.left -= xscroll 
    cr.top -= yscroll 

我運行Windows Vista 32位。

回答

0

沒關係,我弄明白了。我在抽出精靈之前正在繪製一個矩形圖,並最終出現在精靈之下。

+0

確保你點擊接受你自己的答案,所以我們知道這是一個回答的問題:) – hammythepig

+0

我試圖但它說我仍然需要再等23小時 – Chachmu

+0

哦,那麼好吧。這不是非常重要,它只是幫助人們找到仍然需要答案的問題,以便我們提供幫助。不要着急:) – hammythepig

相關問題