質問編集履歴
2
コードに修正を加えました
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,7 +74,9 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
+
root = tkinter.Tk()
|
78
|
+
|
77
|
-
self.bg = PhotoImage(file="background.gif", master=
|
79
|
+
self.bg = PhotoImage(file="background.gif", master=root)
|
78
80
|
|
79
81
|
w = self.bg.width()
|
80
82
|
|
1
コードがなぜか抜けていましたので、改めて書きました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,83 @@
|
|
42
42
|
|
43
43
|
```ここに言語名を入力
|
44
44
|
|
45
|
+
from tkinter import *
|
46
|
+
|
47
|
+
import random
|
48
|
+
|
49
|
+
import time
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
class Game:
|
54
|
+
|
55
|
+
def __init__(self):
|
56
|
+
|
57
|
+
self.tk = Tk()
|
58
|
+
|
59
|
+
self.tk.title("ミスタースティックマンの脱出")
|
60
|
+
|
61
|
+
self.tk.resizable(0, 0)
|
62
|
+
|
63
|
+
self.tk.wm_attributes("-topmost", 1)
|
64
|
+
|
65
|
+
self.canvas = Canvas(self.tk, width=500, height=500, highlightthickness=0)
|
66
|
+
|
67
|
+
self.canvas.pack()
|
68
|
+
|
69
|
+
self.tk.update()
|
70
|
+
|
71
|
+
self.canvas_height = 500
|
72
|
+
|
73
|
+
self.canvas_width = 500
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
self.bg = PhotoImage(file="background.gif", master=frame)
|
78
|
+
|
79
|
+
w = self.bg.width()
|
80
|
+
|
81
|
+
h = self.bg.height()
|
82
|
+
|
83
|
+
for x in range(0, 5):
|
84
|
+
|
85
|
+
for y in range(0, 5):
|
86
|
+
|
87
|
+
self.canvas.create_image(x * w, y * h, image=self.bg, anchor='nw')
|
88
|
+
|
89
|
+
self.sprites = []
|
90
|
+
|
91
|
+
self.runnning = True
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
def mainloop(self):
|
98
|
+
|
45
|
-
|
99
|
+
while 1:
|
100
|
+
|
101
|
+
if self.running == True:
|
102
|
+
|
103
|
+
for sprite in self.sprites:
|
104
|
+
|
105
|
+
sprite.move()
|
106
|
+
|
107
|
+
self.tk.update_idletasks()
|
108
|
+
|
109
|
+
self.tk.update()
|
110
|
+
|
111
|
+
time.sleep(0.01)
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
g = Game()
|
116
|
+
|
117
|
+
g.mainloop()
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
46
122
|
|
47
123
|
```
|
48
124
|
|
@@ -52,7 +128,9 @@
|
|
52
128
|
|
53
129
|
|
54
130
|
|
131
|
+
解答と見比べた
|
132
|
+
|
55
|
-
|
133
|
+
同様の質問がないか調べた
|
56
134
|
|
57
135
|
|
58
136
|
|