igorich1376

Trening-Games-Dx-Ball

Jul 21st, 2024 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.67 KB | None | 0 0
  1. ##
  2. uses wpfobjects;
  3. //
  4. Window.Title := 'Тренировка';
  5. Window.IsFixedSize := true;
  6. Window.Width := 800;
  7. Window.Height := 600;
  8. Window.Clear(Colors.Lightblue);
  9. Window.CenterOnScreen;
  10. //
  11. var X_икс := Window.Width/2-100;
  12. var Rect := new RectangleWPF(Window.Width/2-100, Window.Height/2-50, 200, 50, Colors.Red);
  13. OnKeyDown := k →
  14.   if k = Key.Left then
  15.     begin
  16.       Rect.MoveTo(X_икс,Window.Height/2-50);
  17.       X_икс -= 5;
  18.       if X_икс < 0 then X_икс := 0;
  19.     end
  20.     else if k = Key.Right then
  21.       begin
  22.         Rect.MoveTo(X_икс,Window.Height/2-50);
  23.         X_икс += 5;
  24.         if X_икс > 600 then X_икс := 600;
  25.       end;
  26.  
Advertisement
Add Comment
Please, Sign In to add comment