반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApp1
{
    struct s_watch
    {
        public int milisec;
        public bool status;
    }
    public partial class Form1 : Form
    {
        int board_x = 0;
        int board_y = 0;
        int board_size_x = 0;
        int board_size_y = 0;
 
        int arrow_x = 0;
        int arrow_y = 0;
        int arrow_size_x = 0;
        int arrow_size_y = 0;
 
        int gagebar_x = 0;
        int gagebar_y = 0;
        int gagebar_size_x = 0;
        int gagebar_size_y = 0;
 
        int gagepoint_x = 0;
        int gagepoint_y = 0;
        int gagepoint_size_x = 0;
        int gagepoint_size_y = 0;
 
       
        int powerCount = 0;
        int power = 0;
        bool powermax = false;
        bool gamestate = false;
 
        int highlow_x = 0;
        int highlow_y = 0;
        int highlow_size_x = 0;
        int highlow_size_y = 0;
 
        bool resultState = false;
        s_watch Watch;
        
        public Form1()
        {
            InitializeComponent();
            board_x = (pictureBox1.Width/2 -100- board_size_x;
            board_y = (pictureBox1.Height*(1/17)) - board_size_y;
            board_size_x = 200;
            board_size_y = 200;
 
            arrow_x = (pictureBox1.Width / 2 - 30);
            arrow_y = (pictureBox1.Height -100- arrow_size_y;
            arrow_size_x = 50;
            arrow_size_y = 100;
 
            gagebar_x = pictureBox1.Width - 100;
            gagebar_y = pictureBox1.Height - 500;
            gagebar_size_x = 50;
            gagebar_size_y = 500;
 
            gagepoint_x = pictureBox1.Width - 160;
            gagepoint_y = pictureBox1.Height- 30;
            gagepoint_size_x = 60;
            gagepoint_size_y = 30;
 
        }
 
        
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Image board = Bitmap.FromFile("board.png"); // 이미지로 가져오는 소스
            e.Graphics.DrawImage(board, board_x, board_y, board_size_x, board_size_y);
 
            Image arrow = Bitmap.FromFile("arrow2.png"); // 이미지로 가져오는 소스
            e.Graphics.DrawImage(arrow, arrow_x, arrow_y, arrow_size_x, arrow_size_y);
 
            Image gagebar = Bitmap.FromFile("gagebar.png"); // 이미지로 가져오는 소스
            e.Graphics.DrawImage(gagebar, gagebar_x, gagebar_y, gagebar_size_x, gagebar_size_y);
            
            Image gagepoint = Bitmap.FromFile("gagepoint4.png"); // 이미지로 가져오는 소스
            e.Graphics.DrawImage(gagepoint, gagepoint_x, gagepoint_y , gagepoint_size_x, gagepoint_size_y);
 
            Image highlow = Bitmap.FromFile("highlow.png"); // 이미지로 가져오는 소스
            e.Graphics.DrawImage(highlow, highlow_x, highlow_y, highlow_size_x, highlow_size_y);
 
        }
 
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (Watch.status == false)
            {
                timer1.Enabled = true;
                power = 0;
                powerCount = 0;
                Watch.status = true;
                
            }
            timer2.Enabled = true;
            arrow_y = (pictureBox1.Height) - arrow_size_y;
            gamestate = false;
        }
 
 
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            
            Watch.milisec++;
            if (Watch.milisec > 2)
            {
                Watch.milisec = 0;
                powerCount++;
                power = powerCount * 20;
                if (power > 460) { 
                powerCount = 0;
                powermax = true;
                }
            }
         
            gagepoint_y = pictureBox1.Height -30 - power;
            
            pictureBox1.Invalidate();
 
        }
 
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            arrow_y = (pictureBox1.Height-350- arrow_size_y;
            pictureBox1.Invalidate();
            if (Watch.status == true)
            {
                timer1.Enabled=false;
                Watch.milisec = 0;
                power = powerCount ;
                
                Watch.status = false;
                
            }
            textBox1.Text = "Power = " + power;
            if (resultState == true)
            {
                resultState = false;
                timer2.Enabled = false;
                if (power == 11 && gamestate == false)
                {
                    gamestate = true;
                    MessageBox.Show("10점");       
                }
                else if ((power == 9 || power == 10 || power == 12 || power == 13&& gamestate == false)
                {
                    gamestate = true;
                    MessageBox.Show("8점");
                }
                else if ((power == 7 || power == 8 || power == 14 || power == 15&& gamestate == false)
                {
                    gamestate = true;
                    MessageBox.Show("6점");
                }
                else if ((power == 5 || power == 6 || power == 16 || power == 17&& gamestate == false)
                {
                    gamestate = true;
                    MessageBox.Show("4점");
                }
                else if ((power == 3 || power == 4 || power == 18 || power == 19&& gamestate == false)
                {
                    gamestate = true;
                    MessageBox.Show("2점");
                }
                else  
                {
                    gamestate = true;
                    MessageBox.Show("장외");
                }
                
            }
 
        }
 
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
           
        }
 
        private void timer2_Tick(object sender, EventArgs e)
        {
          
            resultState = true;
            pictureBox1.Invalidate();
 
        }
    }
}
 
cs

 

// 마우스를 누르면 power 게이지가 올라가며, 뗄경우 화살이 날라가며 점수가 출력 된다.

 

 

반응형

'Study > C#' 카테고리의 다른 글

C# 메모장 프로그램  (0) 2021.01.22
C# - 닷지 게임 만들기 결과  (2) 2018.08.31
C# - 닷지 게임 만들기  (0) 2018.08.30
C# - 비행기 자유롭게 움직이기  (0) 2018.08.30
C# - 공튀기기 (particles.js)  (0) 2018.08.30

+ Recent posts