Witam
Muszę stworzyć prostą animacje w C# i potrzebuję pomocy w napisaniu warunku który odbijałby od ściany lecącą kulkę tak żeby nie znikała i instrukcję która startowała animację od nowa (do buttona którego później stworzę). Z góry dzięki za pomoc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Animacja
{
public partial class Form1 : Form
{
int x = 5, y = 150;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
Graphics grafika = this.CreateGraphics();
Pen p = new Pen(Color.Black, 50);
grafika.Clear(Color.Gray);
grafika.DrawEllipse(p, x, y, 50, 50); // wymiary kulki
// kierunek lotu
x = x + 1;
y = y + 1;
}
}
}