/// <summary> /// Constructs the internal sprites needed for our demo. /// </summary> public ViewportMode() { // Create the fragment marbles SurfaceCollection td = LoadMarble("marble1"); SurfaceCollection td2 = LoadMarble("marble2"); // Load the floor SurfaceCollection floorTiles = LoadFloor(); // Place the floors int rows = 8; int cols = 15; size = new Size(floorTiles[0].Size.Width * cols, floorTiles[0].Size.Height * rows); rect = new Rectangle(new Point(0, 0), size); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { // Create the floor tile sprites AnimatedSprite dw = new AnimatedSprite(floorTiles, new Point(i * floorTiles[0].Size.Width, j * floorTiles[0].Size.Height)); Sprites.Add(dw); } } // Load the trigger sprite sprite = new BounceSprite(td2, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td2.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td2.Size.Height), 1)); Sprites.Add(sprite); CenterSprite.Add(sprite); // Load the bouncing sprites for (int i = 0; i < 10; i++) { Thread.Sleep(10); BounceSprite bounceSprite = new BounceSprite(td, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td.Size.Height), 1)); Sprites.Add(bounceSprite); } }
/// <summary> /// Constructs the internal sprites needed for our demo. /// </summary> public BounceMode() { // Create the fragment marbles Rectangle rect = new Rectangle(new Point(0, 0), SpriteDemosMain.Size); for (int i = 0; i < 10; i++) { Thread.Sleep(10); SurfaceCollection d = LoadRandomMarble(); BounceSprite bounceSprite = new BounceSprite(d, new Rectangle(new Point(0, 0), SpriteDemosMain.Size), new Vector(Randomizer.Next(rect.Left, rect.Right), Randomizer.Next(rect.Top, rect.Bottom), 1)); Sprites.Add(bounceSprite); } }
/// <summary> /// Constructs the internal sprites needed for our demo. /// </summary> public MultipleMode() { // Create the fragment marbles SurfaceCollection td = LoadMarble("marble1"); SurfaceCollection td2 = LoadMarble("marble2"); SurfaceCollection td3 = LoadMarble("marble3"); SurfaceCollection td4 = LoadMarble("marble4"); SurfaceCollection td5 = LoadMarble("marble5"); // Load the floor SurfaceCollection floorTiles = LoadFloor(); // Place the floors int rows = 8; int cols = 10; size = new Size(floorTiles[0].Size.Width * cols, floorTiles[0].Size.Height * rows); rect = new Rectangle(new Point(0, 0), size); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { // Create the sprite AnimatedSprite dw = new AnimatedSprite(floorTiles, new Point(i * floorTiles[0].Size.Width, j * floorTiles[0].Size.Height)); this.Sprites.Add(dw); } } // Load the bouncing sprites for (int i = 0; i < 10; i++) { BounceSprite d = new BounceSprite(td, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td.Size.Height), 1)); this.Sprites.Add(d); } // Only one container may be tickable when they all talk to the // same inner tick manager. // Set up container #1 sprite1 = new BounceSprite(td2, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td2.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td2.Size.Height), 1)); this.Sprites.Add(sprite1); // Set up container #2 sprite2 = new BounceSprite(td3, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td3.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td3.Size.Height), 1)); this.Sprites.Add(sprite2); // Set up container #3 sprite3 = new BounceSprite(td4, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td4.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td4.Size.Height), 1)); this.Sprites.Add(sprite3); // Set up container #4 sprite4 = new BounceSprite(td5, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td5.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td5.Size.Height), 1)); this.Sprites.Add(sprite4); surf1 = this.Surface.CreateCompatibleSurface(380, 250); surf2 = this.Surface.CreateCompatibleSurface(380, 250); surf3 = this.Surface.CreateCompatibleSurface(380, 250); surf4 = this.Surface.CreateCompatibleSurface(380, 250); }