コメントに反応がなく詳細が不明なので、普通にVisual Studioを使用しました。
画像を用意するのが面倒なため文字で代用しましたが、ロジックは画像でも使えるはずです。
完成が目標のようなので、非常に冗長ですがわかりやすさを優先しました(個人的にはTimer1_Tick
内のif羅列は配列を使用して、各Click
は共通のイベントハンドラで短縮したいところです)
cs:Form1.cs
1 using System ;
2 using System . Windows . Forms ;
3
4
5 namespace Qb7ezl17qryp65r
6 {
7 public partial class Form1 : Form
8 {
9 private int counter = 0 ;
10
11 public Form1 ( )
12 {
13 InitializeComponent ( ) ;
14 }
15
16 private void Timer1_Tick ( object sender , EventArgs e )
17 {
18 if ( counter == 0 )
19 {
20 // 以下TextはすべてImageに置き換え
21 // 都度Image.FromFileするのは大変無駄なのと、
22 // ==判定できなくなるので同一のImageを使うようにする
23 //cpu.Image = up.Image;
24
25 cpu . Text = up . Text ;
26 }
27 if ( counter == 1 )
28 {
29 cpu . Text = right . Text ;
30 }
31 if ( counter == 2 )
32 {
33 cpu . Text = down . Text ;
34 }
35 if ( counter == 3 )
36 {
37 cpu . Text = left . Text ;
38 }
39 counter ++ ;
40 if ( counter > 3 ) counter = 0 ;
41 }
42
43 private void Button1_Click ( object sender , EventArgs e )
44 {
45 timer1 . Enabled = true ;
46 }
47
48 private void Up_Click ( object sender , EventArgs e )
49 {
50 if ( timer1 . Enabled == false ) return ;
51
52 timer1 . Enabled = false ;
53
54 if ( cpu . Text != up . Text ) MessageBox . Show ( "あなたの勝ちです!" ) ;
55 else MessageBox . Show ( "あなたのまけです!" ) ;
56 }
57
58 private void Right_Click ( object sender , EventArgs e )
59 {
60 if ( timer1 . Enabled == false ) return ;
61
62 timer1 . Enabled = false ;
63
64 if ( cpu . Text != right . Text ) MessageBox . Show ( "あなたの勝ちです!" ) ;
65 else MessageBox . Show ( "あなたのまけです!" ) ;
66 }
67
68 private void Down_Click ( object sender , EventArgs e )
69 {
70 if ( timer1 . Enabled == false ) return ;
71
72 timer1 . Enabled = false ;
73
74 if ( cpu . Text != down . Text ) MessageBox . Show ( "あなたの勝ちです!" ) ;
75 else MessageBox . Show ( "あなたのまけです!" ) ;
76 }
77
78 private void Left_Click ( object sender , EventArgs e )
79 {
80 if ( timer1 . Enabled == false ) return ;
81
82 timer1 . Enabled = false ;
83
84 if ( cpu . Text != left . Text ) MessageBox . Show ( "あなたの勝ちです!" ) ;
85 else MessageBox . Show ( "あなたのまけです!" ) ;
86 }
87 }
88 }
cs:Form1.Designer.cs
1 namespace Qb7ezl17qryp65r
2 {
3 partial class Form1
4 {
5
6
7
8 private System . ComponentModel . IContainer components = null ;
9
10
11
12
13
14 protected override void Dispose ( bool disposing )
15 {
16 if ( disposing && ( components != null ) )
17 {
18 components . Dispose ( ) ;
19 }
20 base . Dispose ( disposing ) ;
21 }
22
23 # region Windows フォーム デザイナーで生成されたコード
24
25
26
27
28
29 private void InitializeComponent ( )
30 {
31 this . components = new System . ComponentModel . Container ( ) ;
32 this . up = new System . Windows . Forms . Label ( ) ;
33 this . right = new System . Windows . Forms . Label ( ) ;
34 this . down = new System . Windows . Forms . Label ( ) ;
35 this . left = new System . Windows . Forms . Label ( ) ;
36 this . cpu = new System . Windows . Forms . Label ( ) ;
37 this . button1 = new System . Windows . Forms . Button ( ) ;
38 this . timer1 = new System . Windows . Forms . Timer ( this . components ) ;
39 this . SuspendLayout ( ) ;
40 //
41 // up
42 //
43 this . up . AutoSize = true ;
44 this . up . Font = new System . Drawing . Font ( "MS UI Gothic" , 60F , System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 128 ) ) ) ;
45 this . up . Location = new System . Drawing . Point ( 256 , 36 ) ;
46 this . up . Name = "up" ;
47 this . up . Size = new System . Drawing . Size ( 116 , 80 ) ;
48 this . up . TabIndex = 0 ;
49 this . up . Text = "👆" ;
50 this . up . Click += new System . EventHandler ( this . Up_Click ) ;
51 //
52 // right
53 //
54 this . right . AutoSize = true ;
55 this . right . Font = new System . Drawing . Font ( "MS UI Gothic" , 60F , System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 128 ) ) ) ;
56 this . right . Location = new System . Drawing . Point ( 314 , 116 ) ;
57 this . right . Name = "right" ;
58 this . right . Size = new System . Drawing . Size ( 116 , 80 ) ;
59 this . right . TabIndex = 1 ;
60 this . right . Text = "👉" ;
61 this . right . Click += new System . EventHandler ( this . Right_Click ) ;
62 //
63 // down
64 //
65 this . down . AutoSize = true ;
66 this . down . Font = new System . Drawing . Font ( "MS UI Gothic" , 60F , System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 128 ) ) ) ;
67 this . down . Location = new System . Drawing . Point ( 256 , 196 ) ;
68 this . down . Name = "down" ;
69 this . down . Size = new System . Drawing . Size ( 116 , 80 ) ;
70 this . down . TabIndex = 2 ;
71 this . down . Text = "👇" ;
72 this . down . Click += new System . EventHandler ( this . Down_Click ) ;
73 //
74 // left
75 //
76 this . left . AutoSize = true ;
77 this . left . Font = new System . Drawing . Font ( "MS UI Gothic" , 60F , System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 128 ) ) ) ;
78 this . left . Location = new System . Drawing . Point ( 192 , 116 ) ;
79 this . left . Name = "left" ;
80 this . left . Size = new System . Drawing . Size ( 116 , 80 ) ;
81 this . left . TabIndex = 3 ;
82 this . left . Text = "👈" ;
83 this . left . Click += new System . EventHandler ( this . Left_Click ) ;
84 //
85 // cpu
86 //
87 this . cpu . AutoSize = true ;
88 this . cpu . Font = new System . Drawing . Font ( "MS UI Gothic" , 60F , System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , ( ( byte ) ( 128 ) ) ) ;
89 this . cpu . Location = new System . Drawing . Point ( 38 , 116 ) ;
90 this . cpu . Name = "cpu" ;
91 this . cpu . Size = new System . Drawing . Size ( 116 , 80 ) ;
92 this . cpu . TabIndex = 4 ;
93 this . cpu . Text = "👆" ;
94 //
95 // button1
96 //
97 this . button1 . Location = new System . Drawing . Point ( 167 , 320 ) ;
98 this . button1 . Name = "button1" ;
99 this . button1 . Size = new System . Drawing . Size ( 75 , 23 ) ;
100 this . button1 . TabIndex = 5 ;
101 this . button1 . Text = "スタート" ;
102 this . button1 . UseVisualStyleBackColor = true ;
103 this . button1 . Click += new System . EventHandler ( this . Button1_Click ) ;
104 //
105 // timer1
106 //
107 this . timer1 . Tick += new System . EventHandler ( this . Timer1_Tick ) ;
108 //
109 // Form1
110 //
111 this . AutoScaleDimensions = new System . Drawing . SizeF ( 6F , 12F ) ;
112 this . AutoScaleMode = System . Windows . Forms . AutoScaleMode . Font ;
113 this . ClientSize = new System . Drawing . Size ( 438 , 376 ) ;
114 this . Controls . Add ( this . button1 ) ;
115 this . Controls . Add ( this . cpu ) ;
116 this . Controls . Add ( this . left ) ;
117 this . Controls . Add ( this . down ) ;
118 this . Controls . Add ( this . right ) ;
119 this . Controls . Add ( this . up ) ;
120 this . Name = "Form1" ;
121 this . Text = "Form1" ;
122 this . ResumeLayout ( false ) ;
123 this . PerformLayout ( ) ;
124
125 }
126
127 # endregion
128
129 private System . Windows . Forms . Label up ;
130 private System . Windows . Forms . Label right ;
131 private System . Windows . Forms . Label down ;
132 private System . Windows . Forms . Label left ;
133 private System . Windows . Forms . Label cpu ;
134 private System . Windows . Forms . Button button1 ;
135 private System . Windows . Forms . Timer timer1 ;
136 }
137 }