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
| uses ABCObjects,Timers,graphABC,Events;
var x,y,i,j,p,k,u,b,n,c,l,t,pr,kardel,sekund,oh,myshnaj:integer;
m:ObjectABC;
q,w,e:PictureABC;
s:string;
war:array [1..150,1..30] of PictureABC;
srav:array [1..150,1..30] of integer;
life,rest,clos,ochki,och:RectangleABC;
timeout:boolean;
t1: Timer;
Procedure Fon;
begin
p:=LoadPicture('12.jpg');
DrawPicture(p,0,0,210,210);
DrawPicture(p,210,0,210,210);
DrawPicture(p,0,210,210,210);
DrawPicture(p,210,210,210,210);
DrawPicture(p,420,0,210,210);
DrawPicture(p,420,210,210,210);
end;
procedure razm;
begin
y:=-6580;
for i:=1 to 100 do
begin x:=0;
for j:=1 to 9 do
begin
k:=random (3)+1;
case k of
1:begin war[i,j]:= CreatePictureABC(x,y,'1.png');srav[i,j]:=1;end;
2:begin war[i,j]:= CreatePictureABC(x,y,'2.png');srav[i,j]:=2;end;
3:begin war[i,j]:= CreatePictureABC(x,y,'3.png');srav[i,j]:=3;end;
end;
x:=x+70;
end;
y:=y+70;
end;
end;
procedure restart;
begin
timeout:=false;
sekund:=300;
if (sekund mod 60)>9 then
life.text:=inttostr(sekund div 60)+' : '+inttostr(sekund mod 60)
else
life.text:=inttostr(sekund div 60)+' : 0'+inttostr(sekund mod 60);
life.visible:=true;
for i:=1 to 100 do begin
for j:=1 to 9 do begin
war[i,j].destroy;
end;end;
fon;
razm;
end;
procedure TimerProc;
begin
if (timeout=false) then sekund:=sekund-1;
if (sekund mod 60)>9 then
life.text:=inttostr(sekund div 60)+' : '+inttostr(sekund mod 60)
else
life.text:=inttostr(sekund div 60)+' : 0'+inttostr(sekund mod 60);
if sekund=0 then begin life.text:='Время вышло!'; timeout:=true;CloseWindow;
end;end;
procedure udal;
begin
b:=0;k:=0;c:=5;n:=98;
//oh:=0;
for i:=95 to 100 do begin
for j:=1 to 9 do begin
//repeat
if(srav[i,j]=srav[i,j+1])and(srav[i,j]=srav[i,j+2])then
begin
war[i,j].destroy;war[i,j+1].destroy;war[i,j+2].destroy; oh:=oh+10;
if srav[i,j]=srav[i,j+3] then begin war[i,j+3].destroy;k:=1; oh:=oh+10;
if srav[i,j]=srav[i,j+4] then begin war[i,j+4].destroy;k:=2; oh:=oh+10;
if srav[i,j]=srav[i,j+5] then begin war[i,j+5].destroy;k:=3; oh:=oh+10;
if srav[i,j]=srav[i,j+6] then begin war[i,j+6].destroy;k:=4; oh:=oh+10;
if srav[i,j]=srav[i,j+7] then begin war[i,j+7].destroy;k:=5; oh:=oh+10;
if srav[i,j]=srav[i,j+8] then begin war[i,j+8].destroy;k:=6; oh:=oh+10;
end;end;end;end;end;end;
case k of
1:begin srav[i,j+3]:=srav[i-1,j+3];for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;
2:begin srav[i,j+4]:=srav[i-1,j+4];srav[i,j+3]:=srav[i-1,j+3];
for u:=1 to n-c do war[i-u,j+4].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;
3:begin srav[i,j+5]:=srav[i-1,j+5];srav[i,j+4]:=srav[i-1,j+4];srav[i,j+3]:=srav[i-1,j+3];
for u:=1 to n-c do war[i-u,j+5].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+4].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;
4:begin srav[i,j+6]:=srav[i-1,j+6];srav[i,j+5]:=srav[i-1,j+5];srav[i,j+4]:=srav[i-1,j+4];srav[i,j+3]:=srav[i-1,j+3];
for u:=1 to n-c do war[i-u,j+6].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+5].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+4].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;
5:begin srav[i,j+7]:=srav[i-1,j+7];srav[i,j+6]:=srav[i-1,j+6];srav[i,j+5]:=srav[i-1,j+5];srav[i,j+4]:=srav[i-1,j+4];srav[i,j+3]:=srav[i-1,j+3];
for u:=1 to n-c do war[i-u,j+7].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+6].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+5].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+4].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;
6:begin srav[i,j+8]:=srav[i-1,j+8];srav[i,j+7]:=srav[i-1,j+7];srav[i,j+6]:=srav[i-1,j+6];srav[i,j+5]:=srav[i-1,j+5];srav[i,j+4]:=srav[i-1,j+4];srav[i,j+3]:=srav[i-1,j+3];
for u:=1 to n-c do war[i-u,j+8].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+7].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+6].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+5].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+4].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+3].MoveOn(0,b+70);end;end;
srav[i,j]:=srav[i-1,j];srav[i,j+1]:=srav[i-1,j+1];srav[i,j+2]:=srav[i-1,j+2];n:=n-1;
for u:=1 to n-c do war[i-u,j].MoveOn(0,b+70);for u:=1 to n-c do war[i-u,j+1].MoveOn(0,b+70);
for u:=1 to n-c do war[i-u,j+2].MoveOn(0,b+70);k:=0;c:=c+1;end;
/////////////////////// until///////////////////////////////////////////////////////////
{ until
(srav[i,j]<>srav[i,j+1]) and (srav[i,j]<>srav[i,j+2]) and
(srav[i,j]<>srav[i,j+3]) and (srav[i,j]<>srav[i,j+4]) and
(srav[i,j]<>srav[i,j+5]) and (srav[i,j]<>srav[i,j+6]) and
(srav[i,j]<>srav[i,j+7]) and (srav[i,j]<>srav[i,j+8]); }
end;end;end;
procedure Mousemove(x,y,mb: integer);
begin
if rest.PtInside(x,y)=true then rest.color:=clyellow else rest.color:=clgreen;
if clos.PtInside(x,y)=true then clos.color:=clyellow else clos.color:=clgreen;
end;
procedure MouseDown(x,y,mb: integer);
begin
if (rest.PtInside(x,y)=true) then restart;
if (clos.PtInside(x,y)=true) then begin closewindow;end;
///if timeout=false then begin
for i:=95 to 100 do begin
for j:=1 to 9 do begin
if (war[i,j].PtInside(x,y)=true)and(war[i,j+1].PtInside(x,y)=true)
then begin war[i,j].MoveOn(+70,0); war[i,j+1].MoveOn(-70,0); end;
if (war[i,j].PtInside(x,y)=true)and(war[i-1,j].PtInside(x,y)=true)
then begin war[i,j].MoveOn(0,-70); war[i-1,j].MoveOn(0,+70);end;
if (war[i,j].PtInside(x,y)=true)and(war[i,j-1].PtInside(x,y)=true)
then begin war[i,j].MoveOn(-70,0); war[i,j-1].MoveOn(+70,0);end;
if (war[i,j].PtInside(x,y)=true)and(war[i+1,j].PtInside(x,y)=true)
then begin war[i,j].MoveOn(0,+70); war[i+1,j].MoveOn(0,-70);end;
end;end; end;//end; //end;
begin
kardel:=0;
s:='Курсовая работа Серёгина Григория "шарики"';
setwindowcaption(s);
SetWindowSize(870,430);
CenterWindow;
fon;
razm;
ochki:=rectangleABC.Create(650,100,200,50,clgreen);
ochki.text:='ОЧКИ';
och:=rectangleABC.Create(700,150,100,50,clgreen);
och.number:=oh;
rest:=rectangleABC.Create(650,250,200,50,clgreen);
rest.text:='НОВАЯ ИГРА';
clos:=rectangleABC.Create(650,350,200,50,clgreen);
clos.text:='ВЫХОД';
t1:=Timer.Create(1000,TimerProc);
life:=rectangleabc.Create(650,20,200,50,clgreen);
sekund:=300; //300 секунд = 5 минут 0 секунд
if (sekund mod 60)>9 then
life.text:=inttostr(sekund div 60)+' : '+inttostr(sekund mod 60)
else
life.text:=inttostr(sekund div 60)+' : 0'+inttostr(sekund mod 60);
udal;
OnMouseDown:=MouseDown;
OnMousemove:=Mousemove;
{case pr of
1:udal;
2:OnMouseDown:=MouseDown;end; }
/// OnMouseDown:=MouseDown;
end. |