質問編集履歴
5
説明の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
```
|
4
4
|
|
5
|
-
mport sys
|
5
|
+
import sys
|
6
6
|
|
7
7
|
import pygame
|
8
8
|
|
4
説明の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,7 +88,7 @@
|
|
88
88
|
|
89
89
|
block.draw()
|
90
90
|
|
91
|
-
pygame.display.update()
|
91
|
+
pygame.display.update()
|
92
92
|
|
93
93
|
```
|
94
94
|
|
3
実行結果の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -91,3 +91,7 @@
|
|
91
91
|
pygame.display.update()コード
|
92
92
|
|
93
93
|
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+

|
2
説明の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
二重ループを用いて6×4のブロック配置をしたいのですがうまくできないです。
|
2
2
|
|
3
3
|
```
|
4
|
+
|
5
|
+
mport sys
|
6
|
+
|
7
|
+
import pygame
|
8
|
+
|
9
|
+
from pygame.locals import QUIT
|
10
|
+
|
11
|
+
from pygame.locals import Rect
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
pygame.init()
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
SURFACE = pygame.display.set_mode((400,300))
|
20
|
+
|
21
|
+
pygame.display.set_caption("pygame window ")
|
22
|
+
|
23
|
+
class Block:
|
24
|
+
|
25
|
+
def __init__(self, color, rect):
|
26
|
+
|
27
|
+
self.color = color #ボールの色(R,G,B)
|
28
|
+
|
29
|
+
self.rect = rect #初期位置と大きさ(Rect を利用)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
def draw(self):
|
34
|
+
|
35
|
+
pygame.draw.rect(SURFACE, self.color, self.rect)
|
36
|
+
|
37
|
+
|
4
38
|
|
5
39
|
left = 50
|
6
40
|
|
1
説明の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,6 +30,30 @@
|
|
30
30
|
|
31
31
|
left = left+50
|
32
32
|
|
33
|
+
|
34
|
+
|
35
|
+
while True:
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
for event in pygame.event.get():
|
40
|
+
|
41
|
+
if event.type == QUIT:
|
42
|
+
|
43
|
+
pygame.quit()
|
44
|
+
|
33
|
-
|
45
|
+
sys.exit()
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
SURFACE.fill((0,0,0))
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
for block in blocks:
|
54
|
+
|
55
|
+
block.draw()
|
56
|
+
|
57
|
+
pygame.display.update()コード
|
34
58
|
|
35
59
|
```
|