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);
}
}
}