Форум программистов, компьютерный форум, киберфорум
Delphi для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.80/5: Рейтинг темы: голосов - 5, средняя оценка - 4.80
0 / 0 / 2
Регистрация: 11.05.2012
Сообщений: 34
1

Подскажите как вынести пару процедур в DLL (игра Сапер)

14.05.2012, 03:14. Показов 906. Ответов 1
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Игра сапер
Нужно перенести в DLL модуль операции по двум процедурам TForm1.N1Click и TForm1.ImageMouseDown
Подскажите как?


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
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
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Menus, StdCtrls;
 
type
  TForm1 = class(TForm)
    mm1: TMainMenu;
    N1: TMenuItem;
    Label1: TLabel;
    procedure N1Click(Sender: TObject);
    procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  img:array[1..7,1..7] of TImage;
  min1array:array[1..49] of Boolean;
  min2array:array[1..7,1..7] of Boolean;
  minanear:array[1..7,1..7] of Byte;
  minaflag:array[1..7,1..7] of Boolean;
  opened:array[1..7,1..7] of Boolean;
  sum : Integer;
  stopgame: Boolean;
implementation
 
{$R *.dfm}
 
procedure TForm1.N1Click(Sender: TObject);
var i,j:Integer;
begin
  stopgame := False;
  sum:=0;
  Label1.Caption:='Игра Началась!';
  for i := 1 to 7 do
    begin
      for j := 1 to 7 do
        begin
          Img[i,j] := TImage.Create(Self);
          Img[i,j].Parent := Self;
          Img[i,j].Left := i*40;
          Img[i,j].Top := j*40;
          Img[i,j].Width := 33;
          Img[i,j].Height := 33;
          Img[i,j].Picture.LoadFromFile('start.bmp');
          img[i,j].OnMouseDown:=ImageMouseDown;
          img[i,j].Tag := j*7-7+i;
          if Random(3) = 0
          then min2array[i,j]:= True
          else min2array[i,j]:= False;
          min1array[j*7-7+i]:=min2array[i,j];
          minanear[i,j]:=0;
          minaflag[i,j]:=False;
          opened[i,j]:=False;
        end;
    end;
  for i := 1 to 7 do
    begin
      for j := 1 to 7 do
        begin
        if (i-1>0) and (j-1>0) then if min2array[i-1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if i-1>0 then if min2array[i-1,j] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i-1>0) and (j+1<8) then if min2array[i-1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        if j-1>0 then if min2array[i,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if j+1<8 then if min2array[i,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i+1<8) and (j-1>0) then if min2array[i+1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if i+1<8 then if min2array[i+1,j] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i+1<8) and (j+1<8) then if min2array[i+1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        end;
    end;
end;
 
procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var i,j:Integer;
begin
  if stopgame = False
  then
    begin
    If Button = mbLeft then
      with Sender as TImage do
      begin
        if min1array[Tag] = True
          then
            begin
              for i := 1 to 7 do
                begin
                 for j := 1 to 7 do
                  begin
                    if min2array[i,j] = True
                    then Img[i,j].Picture.LoadFromFile('bomb.bmp');
                  end;
                end;
              Label1.Caption:='Проигрыш!';
              stopgame := True;
            end
          else
            begin
              i:= Tag div 7+1;
              j:= Tag mod 7;
              if j = 0
                then
                  begin
                    j:=7; i:=i-1
                  end;
              Img[j,i].Picture.LoadFromFile(IntToStr(minanear[j,i])+'.bmp');
              opened[i,j] := True;
            end;
      end;
    If Button = mbRight then
      with Sender as TImage do
      begin
        i:= Tag div 7+1;
        j:= Tag mod 7;
        if j = 0 then
          begin
            j:=7; i:=i-1
          end;
        if opened[i,j] = False then
        begin
          if  minaflag[j,i] = false
          then
            begin
              minaflag[j,i] := True;
              Img[j,i].Picture.LoadFromFile('flag.bmp');
            end
          else
            begin
              minaflag[j,i] := False;
              Img[j,i].Picture.LoadFromFile('start.bmp');
            end;
          for i := 1 to 7 do
          begin
            for j := 1 to 7 do
              begin
                if minaflag[i,j]=min2array[i,j] then
                sum:=sum+1;
              end;
          end;
          if sum = 49 then
            begin
              stopgame := True;
              Label1.Caption:='Победа!';
            end
                      else sum:=0;
        end;
      end;
    end;
end;
 
initialization
  stopgame := False;
  sum := 0;
end.
Вложения
Тип файла: rar sweep.rar (172.0 Кб, 10 просмотров)
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
14.05.2012, 03:14
Ответы с готовыми решениями:

Игра сапер - реализовать интерфейс, как в одноименной игре Windows
Добрый вечер! Сегодня доделал(почти) игру сапер. Она у меня запускается в командной строке и при...

как вынести функции в файл(библиотеку dll)
Как можно создать свою библиотеку или что то подобное и как ее подключить если такое вообще...

Как в dll вынести и использовать Indy компонент?
Случилась проблема, не могу Indy компонент, как и любой другой вынести в DLL для использования? Это...

Как вынести SQL-запрос в отдельную DLL?
добрый день, помогите пожалуйста. Хочу вынести в dll процедуры но не могу понять как заставить ее...

1
0 / 0 / 2
Регистрация: 11.05.2012
Сообщений: 34
14.05.2012, 06:51  [ТС] 2
Такой модуль тоже компилируется, можно как то это все вызвать из пустого приложения по умолчанию?

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
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
library newdll;
 
 
uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Menus, StdCtrls,
  FormShowAbout;
 
 
{$R *.res}
 
 
type
  TForm1 = class(TForm)
    mm1: TMainMenu;
    N1: TMenuItem;
    Label1: TLabel;
    N2: TMenuItem;
    N3: TMenuItem;
    procedure N1Click(Sender: TObject);
    procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure N3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  img:array[1..7,1..7] of TImage;
  min1array:array[1..49] of Boolean;
  min2array:array[1..7,1..7] of Boolean;
  minanear:array[1..7,1..7] of Byte;
  minaflag:array[1..7,1..7] of Boolean;
  opened:array[1..7,1..7] of Boolean;
  sum : Integer;
  stopgame: Boolean;
 
procedure TForm1.N3Click(Sender: TObject);
begin
  ShowAbout(Handle);
end;
 
 
procedure TForm1.N1Click(Sender: TObject);
var i,j:Integer;
begin
  stopgame := False;
  sum:=0;
  Label1.Caption:='Èãðà Íà÷àëàñü!';
  for i := 1 to 7 do
    begin
      for j := 1 to 7 do
        begin
          Img[i,j] := TImage.Create(Self);
          Img[i,j].Parent := Self;
          Img[i,j].Left := i*40;
          Img[i,j].Top := j*40;
          Img[i,j].Width := 33;
          Img[i,j].Height := 33;
          Img[i,j].Picture.LoadFromFile('start.bmp');
          img[i,j].OnMouseDown:=ImageMouseDown;
          img[i,j].Tag := j*7-7+i;
          if Random(3) = 0
          then min2array[i,j]:= True
          else min2array[i,j]:= False;
          min1array[j*7-7+i]:=min2array[i,j];
          minanear[i,j]:=0;
          minaflag[i,j]:=False;
          opened[i,j]:=False;
        end;
    end;
  for i := 1 to 7 do
    begin
      for j := 1 to 7 do
        begin
        if (i-1>0) and (j-1>0) then if min2array[i-1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if i-1>0 then if min2array[i-1,j] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i-1>0) and (j+1<8) then if min2array[i-1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        if j-1>0 then if min2array[i,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if j+1<8 then if min2array[i,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i+1<8) and (j-1>0) then if min2array[i+1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
        if i+1<8 then if min2array[i+1,j] = True then minanear[i,j]:=minanear[i,j]+1;
        if (i+1<8) and (j+1<8) then if min2array[i+1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
        end;
    end;
end;
 
procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var i,j:Integer;
begin
  if stopgame = False
  then
    begin
    If Button = mbLeft then
      with Sender as TImage do
      begin
        if min1array[Tag] = True
          then
            begin
              for i := 1 to 7 do
                begin
                 for j := 1 to 7 do
                  begin
                    if min2array[i,j] = True
                    then Img[i,j].Picture.LoadFromFile('bomb.bmp');
                  end;
                end;
              Label1.Caption:='Ïðîèãðûø!';
              stopgame := True;
            end
          else
            begin
              i:= Tag div 7+1;
              j:= Tag mod 7;
              if j = 0
                then
                  begin
                    j:=7; i:=i-1
                  end;
              Img[j,i].Picture.LoadFromFile(IntToStr(minanear[j,i])+'.bmp');
              opened[i,j] := True;
            end;
      end;
    If Button = mbRight then
      with Sender as TImage do
      begin
        i:= Tag div 7+1;
        j:= Tag mod 7;
        if j = 0 then
          begin
            j:=7; i:=i-1
          end;
        if opened[i,j] = False then
        begin
          if  minaflag[j,i] = false
          then
            begin
              minaflag[j,i] := True;
              Img[j,i].Picture.LoadFromFile('flag.bmp');
            end
          else
            begin
              minaflag[j,i] := False;
              Img[j,i].Picture.LoadFromFile('start.bmp');
            end;
          for i := 1 to 7 do
          begin
            for j := 1 to 7 do
              begin
                if minaflag[i,j]=min2array[i,j] then
                sum:=sum+1;
              end;
          end;
          if sum = 49 then
            begin
              stopgame := True;
              Label1.Caption:='Ïîáåäà!';
            end
                      else sum:=0;
        end;
      end;
    end;
end;
 
 
 
 
exports ShowAbout;
 
begin
  stopgame := False;
  sum := 0;
end.
0
14.05.2012, 06:51
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
14.05.2012, 06:51
Помогаю со студенческими работами здесь

как обозначается в блок схемах модуль,в которых есть пару процедур?.язык pascal
как обозначается в блок схемах модуль,в которых есть пару процедур?.язык pascal.Кому не трудно...

Игра сапер
Дали задание сделать сапера на windows forms, самого примитивного ,но в силу своей неопытности...

игра сапер
Доброго времени суток, господа! У меня следующая проблема: есть код программы на C++ MFC - игра...

Игра Сапер
Выложите кто-нибудь текст игры САПЁРА, программированый на языке С++.-------очень нужно------....


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru