@@ -7,10 +7,10 @@ namespace Snake
7
7
{
8
8
public partial class Game : Form
9
9
{
10
- int VWidth , Width2 , VHeight , Height2 , X , Y , EX , EY , FX , FX2 , FY , FY2 ;
10
+ int VWidth , Width2 , VHeight , Height2 , X , Y , AX , AY , FX , FX2 , FY , FY2 ;
11
11
Direction Direct ;
12
- int [ ] Locations1 = new int [ 9999999 ] ;
13
- int [ ] Locations2 = new int [ 9999999 ] ;
12
+ int [ ] Locations1 = new int [ 999999 ] ;
13
+ int [ ] Locations2 = new int [ 999999 ] ;
14
14
int Queue , Queue2 /*, Queue3*/ , T1 , T2 = 0 ;
15
15
16
16
int Measurement = 5 ;
@@ -49,7 +49,7 @@ private enum Direction
49
49
Up , Down , Left , Right
50
50
}
51
51
52
- private void Drawing ( int EX , int EY )
52
+ private void Drawing ( int AX , int AY )
53
53
{
54
54
Pen Pencil = new Pen ( Color . Black , 5 ) ;
55
55
Graphics Graph = null ;
@@ -59,8 +59,8 @@ private void Drawing(int EX, int EY)
59
59
{
60
60
Graph . DrawRectangle ( Pencil , new Rectangle ( Locations1 [ Queue2 ] , Locations2 [ Queue2 ] , 10 , 10 ) ) ;
61
61
Graph . FillRectangle ( Colored , Locations1 [ Queue2 ] , Locations2 [ Queue2 ] , 10 , 10 ) ;
62
- if ( EX == Locations1 [ Queue2 ] && EY == Locations2 [ Queue2 ] )
63
- AppleEat ( EX , EY ) ;
62
+ if ( AX == Locations1 [ Queue2 ] && AY == Locations2 [ Queue2 ] )
63
+ AppleEat ( AX , AY ) ;
64
64
Queue2 ++ ;
65
65
}
66
66
Pencil . Dispose ( ) ;
@@ -72,16 +72,16 @@ private void Drawing(int EX, int EY)
72
72
Queue2 = Queue ;
73
73
}
74
74
75
- private void AppleEat ( int EX , int EY )
75
+ private void AppleEat ( int AX , int AY )
76
76
{
77
77
Apple = false ;
78
78
Measurement += Growth ;
79
79
Pen Pencil = new Pen ( Color . White , 5 ) ;
80
80
Graphics Graph = null ;
81
81
Graph = CreateGraphics ( ) ;
82
82
SolidBrush Colored = new SolidBrush ( Color . White ) ;
83
- Graph . DrawRectangle ( Pencil , new Rectangle ( EX , EY , 10 , 10 ) ) ;
84
- Graph . FillRectangle ( Colored , EX , EY , 10 , 10 ) ;
83
+ Graph . DrawRectangle ( Pencil , new Rectangle ( AX , AY , 10 , 10 ) ) ;
84
+ Graph . FillRectangle ( Colored , AX , AY , 10 , 10 ) ;
85
85
Pencil . Dispose ( ) ;
86
86
Graph . Dispose ( ) ;
87
87
Colored . Dispose ( ) ;
@@ -134,14 +134,14 @@ private void Gaming_Tick(object sender, EventArgs e)
134
134
if ( Apple == false )
135
135
{
136
136
Apple = true ;
137
- EX = Rastgele . Next ( 50 , VWidth - 50 ) ;
138
- EY = Rastgele . Next ( 50 , VHeight - 50 ) ;
137
+ AX = Rastgele . Next ( 50 , VWidth - 50 ) ;
138
+ AY = Rastgele . Next ( 50 , VHeight - 50 ) ;
139
139
Pen Pencil = new Pen ( Color . Red , 5 ) ;
140
140
Graphics Graph = null ;
141
141
Graph = CreateGraphics ( ) ;
142
142
SolidBrush Colored = new SolidBrush ( Color . Red ) ;
143
- Graph . DrawRectangle ( Pencil , new Rectangle ( EX , EY , 10 , 10 ) ) ;
144
- Graph . FillRectangle ( Colored , EX , EY , 10 , 10 ) ;
143
+ Graph . DrawRectangle ( Pencil , new Rectangle ( AX , AY , 10 , 10 ) ) ;
144
+ Graph . FillRectangle ( Colored , AX , AY , 10 , 10 ) ;
145
145
Pencil . Dispose ( ) ;
146
146
Graph . Dispose ( ) ;
147
147
Colored . Dispose ( ) ;
@@ -152,8 +152,8 @@ private void Gaming_Tick(object sender, EventArgs e)
152
152
Graphics Graph = null ;
153
153
Graph = CreateGraphics ( ) ;
154
154
SolidBrush Colored = new SolidBrush ( Color . Red ) ;
155
- Graph . DrawRectangle ( Pencil , new Rectangle ( EX , EY , 10 , 10 ) ) ;
156
- Graph . FillRectangle ( Colored , EX , EY , 10 , 10 ) ;
155
+ Graph . DrawRectangle ( Pencil , new Rectangle ( AX , AY , 10 , 10 ) ) ;
156
+ Graph . FillRectangle ( Colored , AX , AY , 10 , 10 ) ;
157
157
Pencil . Dispose ( ) ;
158
158
Graph . Dispose ( ) ;
159
159
}
@@ -174,14 +174,14 @@ private void Gaming_Tick(object sender, EventArgs e)
174
174
Locations1 [ Queue2 ] = 99999 ;
175
175
Locations2 [ Queue2 ] = 99999 ;
176
176
}
177
- if ( Width2 == EX && Height2 == EY )
178
- AppleEat ( EX , EY ) ;
177
+ if ( Width2 == AX && Height2 == AY )
178
+ AppleEat ( AX , AY ) ;
179
179
else
180
180
{
181
- FX = Width2 - EX ;
182
- FY = Height2 - EY ;
181
+ FX = Width2 - AX ;
182
+ FY = Height2 - AY ;
183
183
if ( ( Math . Abs ( FX ) >= 0 && Math . Abs ( FX ) <= 8 ) && ( Math . Abs ( FY ) >= 0 && Math . Abs ( FY ) <= 8 ) )
184
- AppleEat ( EX , EY ) ;
184
+ AppleEat ( AX , AY ) ;
185
185
}
186
186
T2 += 50 ;
187
187
if ( T2 >= 1000 )
@@ -233,7 +233,9 @@ private void Game_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
233
233
{
234
234
e . IsInputKey = true ;
235
235
string Key = e . KeyCode . ToString ( ) ;
236
- if ( Continue )
236
+ if ( Key == "Escape" || Key == "escape" )
237
+ Application . Exit ( ) ;
238
+ else if ( Continue )
237
239
{
238
240
if ( Key == "Right" || Key == "right" )
239
241
{
0 commit comments