I am a newbie to game development (and a newbie in this community also), so please do not scold me harshly :]
I decided to learn some basic game programing on C#. Usually i learn few little things before starting something more serious. I've stumbled upon few things, while trying to learn "drawing" basics.
a) What are the ways, to get a curve (path of missile lets say)? I am trying to use Bezier Curves, but they seem kinda... wrong, somehow.
b) Are there any formulas to determine if two Bezier curves have intersected each other? Or any sort of surfaces, like lets say, two ellipses?
c) Need a bit of a help with C# code on this one. Problem is - it's damn slow and i have no idea how to solve this problem, i think that i am doing something wrong when redrawing image, but i am not sure what. Code is a bit... crappy, but, i don't think that this is the actual problem in this case.
Quote:private System.Windows.Forms.Timer timer1; // magical timer private SolidBrush megaBrush = new SolidBrush(Color.Red); private Rectangle rect; // rectangle box private float x1, x2, x3, y1, y2, y3, t; // ignore these for now public Form1() { InitializeComponent(); } private float get3(float i, char cord) // determine point in space { if (cord == 'X') { i = (((1 - i) * (1 - i)) * x1) + (2 * (1 - i) * i * x2) + (i * i * x3); } else { i = (((1 - i) * (1 - i)) * y1) + (2 * (1 - i) * i * y2) + (i * i * y3); } return i; } private void Form1_Load(object sender, EventArgs e) { rect = new Rectangle(0, 0, 30, 30); t = 0.00f; x1 = 0f; y1 = 0f; // p0 x2 = 150f; y2 = 300f; // p1 x3 = 300f; y3 = 0f; // p2 timer1 = new Timer(); timer1.Interval += 50; timer1.Tick += new System.EventHandler(timer1_Tick); timer1.Start(); } private void timer1_Tick(object sender, System.EventArgs e) { Invalidate(); // redraw } private void Form1_Paint(object sender, PaintEventArgs e) { Graphics gMan = e.Graphics; gMan.FillRectangle(megaBrush, rect); rect.X = (int)get3(t, 'X'); rect.Y = (int)get3(t, 'Y'); t += 0.005f; } }