| rotation sample |
| submitted by | user level | date of submission |
| john o扗onnell | intermediate | 04/24/2001 |
download exe: rotationsamplej.zip 6 kb
description of the article
after reading mike golds article on transforms i thought i would get things moving a bit!
overriding the onpaint method and using the timer class allows us to create a simple animation where we rotate a line around a central point.
anyone want to create an asteroids clone in c#? j
source code:
|
using system; using system.drawing; using system.collections; using system.componentmodel; using system.windows.forms; using system.data; using system.drawing.drawing2d; namespace rotationb2 { /// <summary> /// summary description for form1. /// </summary> public class form1 : system.windows.forms.form { private system.windows.forms.timer timer1; private system.componentmodel.icontainer components; public float f=0; public form1() { // // required for windows form designer support // initializecomponent(); // // todo: add any constructor code after initializecomponent call // } /// <summary> /// clean up any resources being used. /// </summary> protected override void dispose( bool disposing ) { if( disposing ) { if (components != null) { components.dispose(); } } base.dispose( disposing ); } #region windows form designer generated code /// <summary> /// required method for designer support – do not modify /// the contents of this method with the code editor. /// </summary> private void initializecomponent() { this.components = new system.componentmodel.container(); this.timer1 = new system.windows.forms.timer(this.components); // // timer1 // this.timer1.enabled = true; this.timer1.interval = 50; this.timer1.tick += new system.eventhandler(this.timer1_tick); // // form1 // this.autoscalebasesize = new system.drawing.size(5, 13); this.clientsize = new system.drawing.size(240, 221); this.name = "form1"; this.text = "rotationb2"; } #endregion /// <summary> /// the main entry point for the application. /// </summary> [stathread] static void main () { application.run(new form1()); } protected override void onpaint(painteventargs e) |
