using System using System Collections Generic using System Linq using

 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace zombie
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
static Random R = new Random();
public MainWindow()
{
InitializeComponent();
}
class smthng {
double x, y;
public smthng(Canvas canvas){
Ellipse el;
el = new Ellipse();
el.Width = 50;
el.Height = 50;
el.Fill = Brushes.Green;
el.Stroke = Brushes.LightGreen;
el.StrokeThickness = 3;
x=R.Next(400,500);
y=R.Next(100,200);
Canvas.SetLeft(el, x);
Canvas.SetTop(el, y);
canvas.Children.Add(el);
DoubleAnimation ANIMA = new DoubleAnimation();
ANIMA.From = Canvas.GetLeft(el);
ANIMA.To = Canvas.GetLeft(el) - 100;
ANIMA.Duration = TimeSpan.FromSeconds(5);
ANIMA.AutoReverse = true;
ANIMA.RepeatBehavior = RepeatBehavior.Forever;
PowerEase XBATITi = new PowerEase();
XBATITi.Power = 2;
XBATITi.EasingMode = EasingMode.EaseInOut;
ANIMA.EasingFunction = XBATITi;
Line body = new Line();
body.X1 = x+25;
body.Y1 = y+100;
body.X2 = x+25;
body.Y2 = y+50;
body.Stroke = Brushes.LightGreen;
body.StrokeThickness = 3;
canvas.Children.Add(body);
DoubleAnimation an1 = new DoubleAnimation();
PowerEase xx = new PowerEase();
xx.Power = 2;
xx.EasingMode = EasingMode.EaseInOut;
an1.EasingFunction = xx;
el.BeginAnimation(Canvas.LeftProperty, ANIMA);
body.BeginAnimation(Canvas.body.X2, xx);
}
}
private void btn_Click(object sender, RoutedEventArgs e)
{
smthng m = new smthng(canvas);
}
}
}