Исходники и листинги ::: Delphi ::: Поймай меня

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
  unit Unit1;
 
  interface
 
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtCtrls;
 
  type
    TForm1 = class(TForm)
      Panel1: TPanel;
      Panel2: TPanel;
      Panel3: TPanel;
      Button1: TButton;
      Button2: TButton;
      Button3: TButton;
      Shape1: TShape;
      Timer1: TTimer;
      procedure FormCreate(Sender: TObject);
      procedure Button2Click(Sender: TObject);
      procedure FormClose(Sender: TObject; var Action: TCloseAction);
      procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
      procedure Button1Click(Sender: TObject);
      procedure Timer1Timer(Sender: TObject);
      procedure Button3Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
 
  var
    Form1: TForm1;
    Dot:Array[1..1000] of TShape;
    n,s,f:integer;
    cf,ct:TColor;
  implementation
 
  uses Unit2;
 
  {$R *.dfm}
 
  procedure TForm1.FormCreate(Sender: TObject);
  begin
  randomize;
  n:=20;
  s:=10;
  ct:=clred;
  cf:=clgreen;
  timer1.Enabled:=false;
 
  end;
 
  procedure TForm1.Button2Click(Sender: TObject);
  var color:integer;
  begin
  timer1.Enabled:=true;
  for f:=1 to n do
  begin
  Dot[f]:=TShape.Create(form1);
  Dot[f].Width:=s;
  Dot[f].Height:=s;
  Dot[f].Top:=random(panel2.Height-s);
  Dot[f].Left:=random(panel2.Width-s);
  color:=random(2);
  if color=0 then Dot[f].Brush.Color:=cf
             else Dot[f].Brush.Color:=ct;
  Dot[f].OnMouseDown:=Shape1MouseDown;
  Dot[f].Parent:=panel2
  end;
  end;
 
  procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  begin
  for f:=1 to n do Dot[f].Free;
  end;
 
  procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
  var p:boolean;
  begin
  Tshape(sender).Visible:=false;
  if TShape(sender).Brush.Color=cf then
  begin
  panel3.Font.Color:=clred;
  panel3.Caption:='НЕУДАЧНИК!!!';
  panel3.Visible:=true;
  panel2.Enabled:=false;
  exit;
  end;
  p:=false;
  for f:=1 to n do
  if (Dot[f].Visible=true) and (Dot[f].Brush.Color=ct) then p:=true;
  if not p then begin
  panel3.Font.Color:=clred;
  panel3.Caption:='Красавчег';
  panel3.Visible:=true;
  panel2.Enabled:=false;
  end;
  end;
 
 
  procedure TForm1.Button1Click(Sender: TObject);
  begin
  form2.showmodal;
  end;
 
  procedure TForm1.Timer1Timer(Sender: TObject);
  begin
  for f:=1 to n do
  begin
  Dot[f].Left:=Dot[f].Left+random(5)-2;
  Dot[f].Top:=Dot[f].Top+random(5)-2;
  if Dot[f].Left<1 then Dot[f].Left:=1;
  if Dot[f].Top<1 then Dot[f].Top:=1;
  if Dot[f].Top>panel2.Height - s then Dot[f].Top:=panel2.Height-s;
  if Dot[f].Left>panel2.Width - s then Dot[f].Left:=panel2.Width-s;
 
 
  end;
  end;
 
  procedure TForm1.Button3Click(Sender: TObject);
  begin
  form1.Close;
  end;
 
  end.
<<< Предыдущая работа

Вернуться в галерею исходников
Поймай меня
Автор: Buinov*
Город: Сургут
Дата: 20.01.2007  13:42
Комментариев: 1
Просмотров: 161
Оценка: 0 (0|0|0|0|0) [0]

Вернуться на главную
Авторский комментарий к работе: Игра Посмотри и всё поймёшь сразу
Вы не можете оценивать

КОММЕНТАРИИ К РАБОТЕ:
No_s[M]oke ::: комментарий от 21.01.2007 | 22:41
No_s[M]oke Сведущий (ур.9)
Очки: 2783
Город:
Тв. работ: 26
Рег: 17.01.2007 (2638)
что за бяка?