Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Общие вопросы Delphi
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 09.05.2016, 11:45   #1
torres0910
Новичок
Джуниор
 
Регистрация: 09.05.2016
Сообщений: 1
По умолчанию Игра "Догонялки"

В игре есть 3 уровня сложности, помогите сделать так , что бы когда таймер достигает 60 секунд игра заканчивалась победой игрока.
Код:
var
  Form1: TForm1;
  Step: Byte = 10;
  Time: Integer = 0;
  Level: Byte = 1;

implementation

uses Unit2, Unit3;

{$R *.dfm}

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Player.Left:=X-Round(Player.Width/2);
  If Y > Bevel1.Top Then
    Player.Top:=Y-Round(Player.Height/2);
end;

procedure TForm1.GameTimerTimer(Sender: TObject);
Var dx,dy: Integer;
begin

  If Player.Left+Player.Width < Enemy.Left Then
    dx:=Player.Left+Player.Width-Enemy.Left
  Else If Enemy.Left+Enemy.Width < Player.Left Then
    dx:=Player.Left-Enemy.Left-Enemy.Width
  Else
    dx:=0;

  If Player.Top+Player.Height < Enemy.Top Then
    dy:=Enemy.Top-Player.Top+Player.Height
  Else If Enemy.Top+Enemy.Height < Player.Top Then
    dy:=Enemy.Top-Enemy.Height-Player.Top
  Else
    dy:=0;

  If (dx = 0) And (dy = 0) Then
  Begin
    GameTimer.Enabled:=False;
    Timer.Enabled:=False;
    LevelTimer.Enabled:=False;
    StartButton.Enabled:=True;
    form2.visible:=true;
    RadioButton1.Enabled:=true;
       RadioButton2.Enabled:=true;
       RadioButton3.Enabled:=true;

    Exit;
  End;

  If (Abs(dx) >= Abs(dy)) And (dx <> 0) Then
    If dx < 0 Then
      Enemy.Left:=Enemy.Left-Step
    Else If dx > 0 Then
      Enemy.Left:=Enemy.Left+Step
  Else Else If (dy <> 0) Then
    If dy < 0 Then
      Enemy.Top:=Enemy.Top+Step
    Else If dy > 0 Then
      Enemy.Top:=Enemy.Top-Step;

end;

procedure TForm1.StartButtonClick(Sender: TObject);
begin
RadioButton1.Enabled:=false;
RadioButton2.Enabled:=false;
RadioButton3.Enabled:=false;
if RadioButton1.Checked = false
or RadioButton2.Checked = false
or RadioButton3.Checked = false
then showmessage('Ошибка.Выберите сложность');

  Time:=0;
  Level:=1;
  GameTimer.Enabled:=True;
  Timer.Enabled:=True;
  LevelTimer.Enabled:=True;
  StartButton.Enabled:=False;
   label1.Caption:='Уровень:1'
end;


procedure TForm1.TimerTimer(Sender: TObject);
begin
  Inc(Time);
  If Time < 60 Then
    TimeLabel.Caption:=IntToStr(Time)+' сек.'
  Else
    TimeLabel.Caption:=IntToStr(Time div 60)+' мин. '+IntToStr(Time mod 60)+' сек.';
end;

procedure TForm1.LevelTimerTimer(Sender: TObject);
begin
  If GameTimer.Interval >= 10 Then
  Begin
    GameTimer.Interval:=GameTimer.Interval-9;
    Inc(Level);
    label1.Caption:='Уровень:'+IntToStr(Level);
  End
  Else
  Begin
    GameTimer.Enabled:=False;
    Timer.Enabled:=False;
    LevelTimer.Enabled:=False;
    StartButton.Enabled:=True;
     form3.visible:=true;

  End;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
GameTimer.Interval:=100;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
 GameTimer.Interval:=200;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
 GameTimer.Interval:=300;
end;

end.
Вложения
Тип файла: rar 55.rar (431.5 Кб, 12 просмотров)
torres0910 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Для заданной строки определить все входящие в неё символ. Например: строка "abccbbabbac" состоит из символов "a", "b" и "c" Sandakan01 Помощь студентам 1 24.02.2016 03:20
игра "worms", доработка игры "косынка". C# den790 Фриланс 11 09.12.2011 10:53