Advertisement
ksyshshot

Lab.6.1

Apr 28th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.67 KB | Source Code | 0 0
  1. implementation
  2.  
  3. {$R *.dfm}
  4.  
  5. uses UnitAbout, UnitError, UnitExit, UnitInstruction_6_1;
  6.  
  7. const EXIT_VALUE = 1;
  8.  
  9. procedure TFormWalkingMan.ButtonAboutClick(Sender: TObject);
  10. begin
  11.     UnitAbout.FormAbout.ShowModal();
  12. end;
  13.  
  14. procedure TFormWalkingMan.ButtonTaskClick(Sender: TObject);
  15. begin
  16.     UnitInstruction_6_1.FormInstruction.ShowModal;
  17. end;
  18.  
  19. procedure TFormWalkingMan.FormCloseQuery(Sender: TObject;
  20.   var CanClose: Boolean);
  21. begin
  22.     CanClose := UnitExit.FormExit.ShowModal = EXIT_VALUE;
  23. end;
  24.  
  25. procedure TFormWalkingMan.FormCreate(Sender: TObject);
  26. begin
  27.     Timer.Enabled := false;
  28. end;
  29.  
  30. procedure TFormWalkingMan.FormKeyPress(Sender: TObject; var Key: Char);
  31. begin
  32.     if Key = #13 then
  33.     begin
  34.         Man.Left := 8;
  35.         BodyDefault.Visible := false;
  36.         GIFImageDefaultAnimate := True;
  37.         try
  38.             Man.Picture.LoadFromFile('Man.gif');
  39.             Man.Transparent := true;
  40.             Man.Visible := true;
  41.             Timer.Enabled := true;
  42.         except
  43.             UnitError.FormError.LabelError.Caption := 'Не найден файл с необходимым изображением!';
  44.             UnitError.FormError.ShowModal;
  45.             UnitError.FormError.LabelError.Caption := '';
  46.         end;
  47.     end;
  48. end;
  49.  
  50. function CheckFormEnd(CurrPos, FormWidth: Integer; var Man: TImage): Boolean;
  51. begin
  52.     if (CurrPos > FormWidth) then
  53.     begin
  54.         Man.Visible := false;
  55.         CheckFormEnd := false;
  56.     end
  57.     else
  58.         CheckFormEnd := true;
  59. end;
  60.  
  61. procedure TFormWalkingMan.TimerTimer(Sender: TObject);
  62. begin
  63.     Man.Left := Man.Left + 5;
  64.     Timer.Enabled := CheckFormEnd(Man.Left, Width, Man);
  65. end;
  66.  
  67. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement