I cant figure out why this isnt animating >=/
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _D_game_01
{
public partial class GForm : Form
{
Point BallLocation = new Point(10, 10);
Size BallSize = new Size();
Point LinePoint1 = new Point();
Point LinePoint2 = new Point();
int[] buffer = new int[1] { 0 };
public GForm()
{
InitializeComponent();
}
private void GPanel_Paint(object sender, PaintEventArgs e)
{
Graphics G = e.Graphics;
G.Clear(Color.CornflowerBlue);
SetupLines(sender, e);
SetupBall(sender, e);
this.Invalidate();
}
private void SetupLines(object sender, PaintEventArgs e)
{
try
{
e.Graphics.DrawLine(Pens.Black, LinePoint1 = new Point(0, e.ClipRectangle.Height / 6 * 5), LinePoint2 = new Point(e.ClipRectangle.Width, e.ClipRectangle.Height / 6 * 5));
}
catch { }
}
private void SetupBall(object sender, PaintEventArgs e)
{
try
{
e.Graphics.DrawArc(Pens.Black, new Rectangle(BallLocation, BallSize = new Size(e.ClipRectangle.Height / 10, e.ClipRectangle.Height / 10)), 0, 360);
}
catch { }
}
private void Tmr_Update_Tick(object sender, EventArgs e)
{
try
{
BallLocation.Y += buffer[0];
if (BallLocation.Y < LinePoint1.Y - BallSize.Height)
buffer[0] += 1;
if (BallLocation.Y >= LinePoint1.Y - BallSize.Height)
buffer[0] = 0;
if (BallLocation.Y > LinePoint1.Y - BallSize.Height)
BallLocation.Y = LinePoint1.Y - BallSize.Height;
}
catch { }
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == (byte)Keys.Escape)
this.Close();
}
}
}
This is suposed to animate... I can't figure out why it doesnt. I've done this before. Why isnt it animating this time ^^
______________________________
Thanks in advance!
Dahwan

