Click here to Skip to main content
15,888,195 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys, I'm trying to simulate a rectangle that moves with a velocity of V from point A to point B. The two points are connected through a line that I draw by overriding the OnPaint method of a Form.

The thing that looks like a challenge to me is how to set when the location of the rectangle should be updated. Am I going to need a timer? or ...


Any idea is appreciated!

Thanks in advance
Posted

You need timer, and use that in tick event, set the co-ordinates of the rectangle and validate the form.
 
Share this answer
 
You can use timer and in tick event set the coordinates of rectangle and invalidate the form to refresh it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900