public override void Initialize() { // Create the propeller blades from triangles. Shape lBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape rBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape tBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape hub = new Shapes.Circle(new Vector2(0, 0), 10); // Rotate the blades so they are 120 degrees apart. rBlade.Rotate(new Vector2(0, 0), 120); tBlade.Rotate(new Vector2(0, 0), 240); // Add the blades to the list of shapes for rendering. propeller.Add(lBlade); propeller.Add(rBlade); propeller.Add(tBlade); propeller.Add(hub); // Create the base of the windmill. stand = new Shapes.Triangle(new Vector2(0, 0), new Vector2(-20, 300), new Vector2(20, 300)); // Setup initial position, scale and rotation based on the transform. foreach (Shape blade in propeller) { blade.Rotate(new Vector2(0, 0), Transform.Rotation); blade.Scale(new Vector2(0, 0), Transform.Scale); blade.Translate(Transform.Position); } stand.Rotate(new Vector2(0, 0), Transform.Rotation); stand.Scale(new Vector2(0, 0), Transform.Scale); stand.Translate(Transform.Position); }
/// <summary> /// Initialize the scene. /// </summary> public override void Initialize() { // Create the propeller blades from triangles, and hub from circle. Shape lBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape rBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape tBlade = new Shapes.Triangle(new Vector2(0, 0), new Vector2(150, 0), new Vector2(10, 20)); Shape hub = new Shapes.Circle(new Vector2(0, 0), 10); // Create the base of the windmill. stand = new Shapes.Triangle(new Vector2(0, 0), new Vector2(-20, 300), new Vector2(20, 300)); // Create the grass. grass = new Shapes.Rectangle(0, 500, 800, 300); // Create the sky. sky = new Shapes.Rectangle(0, 0, 800, 500); // Create the clouds. (Probably a little inefficient to use circles). cloud = new List <Shape>(); cloud.Add(new Circle(new Vector2(0, 0), 50)); cloud.Add(new Circle(new Vector2(60, 10), 35)); cloud.Add(new Circle(new Vector2(100, 10), 25)); cloud.Add(new Circle(new Vector2(0, 0), 50)); cloud.Add(new Circle(new Vector2(-60, 10), 40)); cloud.Add(new Circle(new Vector2(-100, 15), 20)); foreach (Shape shape in cloud) { shape.Translate(new Vector2(100, 100)); } // Rotate the blades so they are 120 degrees apart. rBlade.Rotate(new Vector2(0, 0), 120); tBlade.Rotate(new Vector2(0, 0), 240); // Add the blades to the list of shapes for rendering. propeller.Add(lBlade); propeller.Add(rBlade); propeller.Add(tBlade); propeller.Add(hub); // Translate the blades to their location. Vector2 position = new Vector2(400, 200); stand.Translate(position); foreach (Shape shape in propeller) { shape.Translate(position); } }