Нужно написать програму с использованием анимации - C#

Узнай цену своей работы

Формулировка задачи:

Помогите плз. Я ещё не выучил графику в с#, а програму уже нужно написать програма на свободную тематику.

Решение задачи: «Нужно написать програму с использованием анимации»

textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication23
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
            Timer timer = new Timer();
            timer.Interval = 10;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Enabled = true;
        }
 
        Point location = new Point(50,50);
        Point speed = new Point(5,3);
 
        void timer_Tick(object sender, EventArgs e)
        {
            Refresh();
            Graphics gr = Graphics.FromHwnd(this.Handle);
            gr.FillEllipse(Brushes.HotPink, location.X, location.Y, 10, 10);
            location = new Point(location.X + speed.X, location.Y + speed.Y);
            if (location.X + 10 > ClientRectangle.Width || location.X < 0)
                speed = new Point(-speed.X, speed.Y);
            if (location.Y + 10 > ClientRectangle.Height || location.Y < 0)
                speed = new Point(speed.X, -speed.Y);
        }
    }
}

Оцени полезность:

12   голосов , оценка 3.917 из 5
Похожие ответы