コードと同じファイルに画像があるのに画像のようなエラーが表記されます。
原因は何でしょうか?
ちなみに下がコードです。
python
1コードimport tkinter 2import random 3 4index=0 5timer=0 6score=0 7hisc=1000 8difficulty=0 9tsugi=0 10 11cursor_x=0 12cursor_y=0 13mouse_x=0 14mouse_y=0 15mouse_c=0 16 17def mouse_move(e): 18 global mouse_x,mouse_y 19 mouse_x=e.x 20 mouse_y=e.y 21 22def mouse_press(e): 23 global mouse_c 24 mouse_c=1 25 26neko=[] 27check=[] 28for i in range(10): 29 neko.append([0,0,0,0,0,0,0,0]) 30 check.append([0,0,0,0,0,0,0,0]) 31 32def draw_neko(): 33 cvs.delete("NEKO") 34 for y in range(10): 35 for x in range(8): 36 if neko[y][x]>0: 37 cvs.create_image(x*72+60,y*72+60,image=img_neko[neko[y][x]],tag="NEKO") 38 39def check_neko(): 40 for y in range(10): 41 for x in range(8): 42 check[y][x]=neko[y][x] 43 44 for y in range(1,9): 45 for x in range(8): 46 if check[y][x]>0: 47 if check[y-1][x]==check[y][x] and check[y+1][x]==check[y][x]: 48 neko[y-1][x]=7 49 neko[y][x]=7 50 neko[y+1][x]=7 51 52 for y in range(10): 53 for x in range(1,7): 54 if check[y][x]>0: 55 if check[y][x-1]==check[y][x] and check[y][x+1]==check[y][x]: 56 neko[y][x-1]=7 57 neko[y][x]=7 58 neko[y][x+1]=7 59 60 for y in range(1,9): 61 for x in range(1,7): 62 if check[y][x]>0: 63 if check[y-1][x-1]==check[y][x] and check[y+1][x+1]==check[y][x]: 64 neko[y-1][x-1]=7 65 neko[y][x]=7 66 neko[y+1][x+1]=7 67 if check[y+1][x-1]==check[y][x] and check[y-1][x+1]==check[y][x]: 68 neko[y+1][x-1]=7 69 neko[y][x]=7 70 neko[y-1][x+1]=7 71 72def sweep_neko(): 73 num=0 74 for y in range(10): 75 for x in range(8): 76 if neko[y][x]==7: 77 neko[y][x]=0 78 num=num+1 79 return num 80 81def drop_neko(): 82 flg=False 83 for y in range(8,-1,-1): 84 for x in range(8): 85 if neko[y][x] != 0 and neko[y+1][x]==0: 86 neko[y+1][x]=neko[y][x] 87 neko[y][x]=0 88 flg=True 89 return flg 90 91def over_neko(): 92 for x in range(8): 93 if neko[0][x]>0: 94 return True 95 return False 96 97def set_neko(): 98 for x in range(8): 99 neko[0][x]=random.randint(0,difficulty) 100 101def draw_txt(txt,x,y,siz,col,tg): 102 fnt=("Times New Roman",siz,"bold") 103 cvs.create_text(x+2,y+2,text=txt,fill="black",font=fnt,tag=tg) 104 cvs.create_text(x,y,text=txt,fill=col,font=fnt,tag=tg) 105 106def game_main(): 107 global index,timer,score,hisc,difficulty,tsugi 108 global cursor_x,cursor_y,mouse_c 109 if index==0: 110 draw_txt("猫猫",312,240,100,"violet","TITLE") 111 cvs.create_rectangle(168,384,456,456,fill="skyblue",width=0,tag="TITLE") 112 draw_txt("Easy",312,420,40,"white","TITLE") 113 cvs.create_rectangle(168,528,456,600,fill="lightgreen",width=0,tag="TITLE") 114 draw_txt("Nowmal",312,564,40,"white","TITLE") 115 cvs.create_rectangle(168,672,456,744,fill="orange",width=0,tag="TITLE") 116 draw_txt("Hard",312,708,40,"white","TITLE") 117 index=1 118 mouse_c=0 119 elif index==1: 120 difficulty=0 121 if mouse_c==1: 122 if 168<mouse_x and mouse_x<456 and 384<mouse_y and mouse_y<456: 123 difficulty=4 124 if 168<mouse_x and mouse_x<456 and 528<mouse_y and mouse_y<600: 125 difficulty=5 126 if 168<mouse_x and mouse_x<456 and 672<mouse_y and mouse_y<744: 127 difficulty=6 128 if difficulty>0: 129 for y in range(10): 130 for x in range(8): 131 neko[y][x]=0 132 mouse_c=0 133 score=0 134 tsugi=0 135 cursor_x=0 136 cursor_y=0 137 set_neko() 138 draw_neko() 139 cvs.delete("TITLE") 140 index=2 141 elif index==2: 142 if drop_neko()==False: 143 index=3 144 draw_neko() 145 elif index==3: 146 check_neko() 147 draw_neko() 148 index=4 149 elif index ==4: 150 sc = sweep_neko() 151 score=score+sc*difficulty*2 152 if score>hisc: 153 hisc=score 154 if sc>0: 155 index=2 156 else: 157 if over_neko()==False: 158 tsugi=random.randint(1,difficulty) 159 index=5 160 else: 161 index=6 162 timer=0 163 draw_neko() 164 elif index == 5: 165 if 24<=mouse_x and mouse_x<24+72*8 and 24<=mouse_x and mouse_y<24+72*10: 166 cursor_x=int((mouse_x-24)/72) 167 cursor_y=int((mouse_y-24)/72) 168 if mouse_c==1: 169 mouse_c=0 170 set_neko() 171 neko[cursor_y][cursor_x]=tsugi 172 tsugi=0 173 index=2 174 cvs.delete("CURSOR") 175 cvs.create_image(cursor_x*72+60,cursor_y+72+60,image=cursor,tag="CURSOR") 176 draw_neko() 177 elif index == 6: 178 timer = timer+1 179 if timer == 1: 180 draw_txt("GAME OVER",312,348,60,"red","OVER") 181 if timer == 50: 182 cvs.delete("OVER") 183 index=0 184 cvs.delete("INFO") 185 draw_txt("SCORE"+str(hisc),160,60,32,"blue","INFO") 186 draw_txt("HISC"+str(hisc),450,60,32,"yellow","INFO") 187 if tsugi>0: 188 cvs.create_image(752,128,image=img_neko[tsugi],tag="INFO") 189 root.after(100,game_main) 190 191root=tkinter.Tk() 192root.title("落ち物パズル「ねこねこ」") 193root.resizable(False,False) 194root.bind("<Motion>",mouse_move) 195root.bind("<ButtonPress>",mouse_press) 196cvs = tkinter.Canvas(root,width=912,height=768) 197cvs.pack() 198 199bg = tkinter.PhotoImage(file="neko_bg.png") 200cursor= tkinter.PhotoImage(file="neko_cursor.png") 201img_neko=[ 202 None, 203 tkinter.PhotoImage(file="nako1.png"), 204 tkinter.PhotoImage(file="neko2.png"), 205 tkinter.PhotoImage(file="neko3.png"), 206 tkinter.PhotoImage(file="neko4.png"), 207 tkinter.PhotoImage(file="neko5.png"), 208 tkinter.PhotoImage(file="neko6.png"), 209 tkinter.PhotoImage(file="neko_niku.png") 210] 211 212cvs.create_image(456,384,image=bg) 213game_main() 214root.mainloop() 215