public void AdvanceFrame() { // Move all things by one step, accounting for gravity for (int thingIndex = 0; thingIndex < this.things.Count; thingIndex++) { Thing thing = this.things[thingIndex]; thing.Center.Offset(thing.XVelocity, thing.YVelocity); thing.YVelocity += this.gravity * this.sceneRect.Height; // 중력 thing.YVelocity *= this.airFriction; thing.XVelocity *= this.airFriction; thing.Theta += thing.SpinRate; // 바닥으로 떨어지는것 방지 if (thing.Center.Y > thing.GetFirstY()) { thing.Center.Y = thing.GetFirstY(); } // bounce off walls if ((thing.Center.X - thing.Size < 0) || (thing.Center.X + thing.Size > this.sceneRect.Width)) { thing.XVelocity = -thing.XVelocity; thing.Center.X += thing.XVelocity; } // Then get rid of one if any that fall off the bottom if (thing.Center.Y - thing.Size > this.sceneRect.Bottom) { thing.State = ThingState.Remove; } // Get rid of after dissolving. if (thing.State == ThingState.Dissolving) { thing.Dissolve += 1 / (this.targetFrameRate * DissolveTime); thing.Size *= this.expandingRate; if (thing.Dissolve >= 0.1) { thing.State = ThingState.Remove; MainWindow.ImageSave("Snap_" + thing.GetFirstX() + "_" + thing.GetFirstY()); } } this.things[thingIndex] = thing; } // Then remove any that should go away now for (int i = 0; i < this.things.Count; i++) { Thing thing = this.things[i]; if (thing.State == ThingState.Remove) { this.things.Remove(thing); i--; } } // Create any new things to drop based on dropRate if ((this.things.Count < this.maxThings) && (this.rnd.NextDouble() < this.dropRate / this.targetFrameRate) && (this.polyTypes != PolyType.None)) { PolyType[] alltypes = { PolyType.Triangle, PolyType.Square, PolyType.Star, PolyType.Pentagon, PolyType.Hex, PolyType.Star7, PolyType.Circle, PolyType.Bubble }; byte r; byte g; byte b; if (this.doRandomColors) { r = (byte)(this.rnd.Next(215) + 40); g = (byte)(this.rnd.Next(215) + 40); b = (byte)(this.rnd.Next(215) + 40); } else { r = (byte)Math.Min(255.0, this.baseColor.R * (0.7 + (this.rnd.NextDouble() * 0.7))); g = (byte)Math.Min(255.0, this.baseColor.G * (0.7 + (this.rnd.NextDouble() * 0.7))); b = (byte)Math.Min(255.0, this.baseColor.B * (0.7 + (this.rnd.NextDouble() * 0.7))); } PolyType tryType; do { tryType = alltypes[this.rnd.Next(alltypes.Length)]; }while ((this.polyTypes & tryType) == 0); // this.DropNewThing(tryType, this.shapeSize, System.Windows.Media.Color.FromRgb(r, g, b)); } }