I cant figure out why this isnt animating >=/

using System;
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
[2692 byte] By [dahwan] at [2007-11-20 11:34:55]
# 1 Re: I cant figure out why this isnt animating >=/
where are you creating your timer?
laitinen at 2007-11-9 11:36:56 >
# 2 Re: I cant figure out why this isnt animating >=/
I created the timer in the designer. It's enabled with an interval of 10.
dahwan at 2007-11-9 11:37:57 >
# 3 Re: I cant figure out why this isnt animating >=/
Seems the timer isnt working at all =/
If all my code in the timer tick is

this.Text += "a";

The window title doesnt change at all.

Whats wrong with the timer? =O
dahwan at 2007-11-9 11:38:56 >
# 4 Re: I cant figure out why this isnt animating >=/
Hi

Check, Whether time is enable or not,

Check after loading the form or at the time of loading form

Regards
Ravi.Battula
battula32 at 2007-11-9 11:39:51 >
# 5 Re: I cant figure out why this isnt animating >=/
That is because of this line of code: this.Invalidate(); in your paint handler. Please try to debug your program and see what happens. In addition I think you have some bugs in your timer function. Review the whole program.

Laitinen
laitinen at 2007-11-9 11:40:50 >
# 6 Re: I cant figure out why this isnt animating >=/
The bugs in the timer function doesnt matter :) It's not even started yet. I will keep that going after i've gotten the timer to work.
I removed Invalidate(), but it still isnt moving
dahwan at 2007-11-9 11:42:00 >
# 7 Re: I cant figure out why this isnt animating >=/
OK, i moved this.Invalidate() from the paint onverride to the Timer tick :)

Working =D

Thanks!
dahwan at 2007-11-9 11:42:53 >