質問編集履歴

2

コードの追加

2019/08/17 00:18

投稿

kinopi
kinopi

スコア16

test CHANGED
File without changes
test CHANGED
@@ -7,3 +7,103 @@
7
7
  ###2.3つ揃ったら勝ちみたいにするやり方
8
8
 
9
9
  この二つのやり方を教えてください!
10
+
11
+ ```python
12
+
13
+ # -*- coding:utf-8 -*-
14
+
15
+ import pygame
16
+
17
+ from pygame.locals import *
18
+
19
+ import sys
20
+
21
+
22
+
23
+ def main():
24
+
25
+ pygame.init() # Pygameの初期化
26
+
27
+ screen = pygame.display.set_mode((400, 400)) # 400*300の画面
28
+
29
+ # screen = pygame.display.set_mode((400, 300), FULLSCREEN) # フルスクリーン(解除時は大きさ400*300の画面)
30
+
31
+ pygame.display.set_caption("○×ゲーム") # タイトルバーに表示する文字
32
+
33
+
34
+
35
+ while (1):
36
+
37
+ screen.fill((0,0,0)) # 画面を黒色(#000000)に塗りつぶし
38
+
39
+
40
+
41
+ button1 = pygame.Rect(0,0,40,40)
42
+
43
+ button2 = pygame.Rect(0,45,40,40)
44
+
45
+ button3 = pygame.Rect(0,90,40,40)
46
+
47
+ button4 = pygame.Rect(45,0,40,40)
48
+
49
+ button5 = pygame.Rect(45,45,40,40)
50
+
51
+ button6 = pygame.Rect(45,90,40,40)
52
+
53
+ button7 = pygame.Rect(90,0,40,40)
54
+
55
+ button8 = pygame.Rect(90,45,40,40)
56
+
57
+ button9 = pygame.Rect(90,90,40,40)
58
+
59
+
60
+
61
+ pygame.draw.rect(screen,(100,100,100),button1)
62
+
63
+ pygame.draw.rect(screen,(100,100,100),button2)
64
+
65
+ pygame.draw.rect(screen,(100,100,100),button3)
66
+
67
+ pygame.draw.rect(screen,(100,100,100),button4)
68
+
69
+ pygame.draw.rect(screen,(100,100,100),button5)
70
+
71
+ pygame.draw.rect(screen,(100,100,100),button6)
72
+
73
+ pygame.draw.rect(screen,(100,100,100),button7)
74
+
75
+ pygame.draw.rect(screen,(100,100,100),button8)
76
+
77
+ pygame.draw.rect(screen,(100,100,100),button9)
78
+
79
+
80
+
81
+ pygame.display.update() # 画面を更新
82
+
83
+
84
+
85
+ # イベント処理
86
+
87
+ for event in pygame.event.get():
88
+
89
+ if event.type == QUIT: # 閉じるボタンが押されたら終了
90
+
91
+ pygame.quit() # Pygameの終了(画面閉じられる)
92
+
93
+ sys.exit()
94
+
95
+ for event in pygame.event.get():
96
+
97
+ if event.type == pygame.MOUSEBUTTONDOWN:
98
+
99
+ if button1.collidepoint(event.pos):
100
+
101
+
102
+
103
+
104
+
105
+ if __name__ == "__main__":
106
+
107
+ main()
108
+
109
+ ```

1

本文の修正

2019/08/17 00:18

投稿

kinopi
kinopi

スコア16

test CHANGED
@@ -1 +1 @@
1
- pygameの長方形の色変更
1
+ pygameの長方形の色変更をしたい
test CHANGED
@@ -6,4 +6,4 @@
6
6
 
7
7
  ###2.3つ揃ったら勝ちみたいにするやり方
8
8
 
9
- (要するに大体わかませんでした(笑))
9
+ この二つのや方を教えてください!