Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Author: MaxK - MarekM 30.12.2025 (reddit: u/Glad-Journalist-4807)
- param(
- # [int]$SkipIntro = 1,
- # [string]$Music = "f.mid",
- # [double]$MusVolume = 0.20,
- # [string]$Boom1 = "a.wav",
- # [string]$Boom2 = "b.wav",
- # [string]$Boom3 = "c.wav",
- # [string]$Background = "h.jpg",
- [int]$SnowTick = 70,
- [int]$SparkTick = 40,
- [int]$FlakeCount = 50,
- [int]$SparkCount = 25
- ) #only 1st param is working
- Add-Type -AssemblyName PresentationFramework
- Add-Type -AssemblyName WindowsBase
- Add-Type -AssemblyName PresentationCore
- Add-Type -AssemblyName System.Windows.Forms
- $SCRIPT_DIR = $PSScriptRoot
- $script:Gravity = 0.5
- $script:ExplosionForce = 15
- $script:AirResistance = 0.015
- $script:deltaTime = 1.0
- $script:maxSnowSpeed = 500
- $script:SNOW_GRAVITY_SCALE = 3
- $script:SNOW_AIRDRAG_SCALE = 2
- $script:PHYSICS_SCALE = 100
- $script:SNOW_AIR_DRAG_SCALED = $script:AirResistance * $script:PHYSICS_SCALE / 50
- $script:SNOW_GRAVITY_SCALED = $script:Gravity * $script:SNOW_GRAVITY_SCALE / 5
- $script:AIR_RESISTANCE_ABS = [Math]::Abs($airResistance)
- $script:DARK_ENERGY_FORCE = $script:AIR_RESISTANCE_ABS * 10 * $deltaTime
- $ColorsRed = @(
- [System.Windows.Media.Colors]::LightPink,
- [System.Windows.Media.Colors]::Pink,
- [System.Windows.Media.Colors]::LightCoral,
- [System.Windows.Media.Colors]::Salmon,
- [System.Windows.Media.Colors]::Coral,
- [System.Windows.Media.Colors]::Tomato,
- [System.Windows.Media.Colors]::OrangeRed,
- [System.Windows.Media.Colors]::Red,
- [System.Windows.Media.Colors]::Crimson,
- [System.Windows.Media.Colors]::Firebrick
- )
- $ColorsPurple = @(
- [System.Windows.Media.Colors]::LavenderBlush,
- [System.Windows.Media.Colors]::Lavender,
- [System.Windows.Media.Colors]::Thistle,
- [System.Windows.Media.Colors]::Plum,
- [System.Windows.Media.Colors]::Violet,
- [System.Windows.Media.Colors]::Orchid,
- [System.Windows.Media.Colors]::MediumOrchid,
- [System.Windows.Media.Colors]::DarkOrchid,
- [System.Windows.Media.Colors]::BlueViolet,
- [System.Windows.Media.Colors]::MediumPurple
- )
- $ColorsGreen = @(
- [System.Windows.Media.Colors]::Honeydew,
- [System.Windows.Media.Colors]::MintCream,
- [System.Windows.Media.Colors]::PaleGreen,
- [System.Windows.Media.Colors]::LightGreen,
- [System.Windows.Media.Colors]::SpringGreen,
- [System.Windows.Media.Colors]::LimeGreen,
- [System.Windows.Media.Colors]::Lime,
- [System.Windows.Media.Colors]::ForestGreen,
- [System.Windows.Media.Colors]::Green,
- [System.Windows.Media.Colors]::DarkGreen
- )
- $ColorsYellow = @(
- [System.Windows.Media.Colors]::LightYellow,
- [System.Windows.Media.Colors]::LemonChiffon,
- [System.Windows.Media.Colors]::LightGoldenrodYellow,
- [System.Windows.Media.Colors]::PapayaWhip,
- [System.Windows.Media.Colors]::Moccasin,
- [System.Windows.Media.Colors]::PeachPuff,
- [System.Windows.Media.Colors]::Gold,
- [System.Windows.Media.Colors]::Goldenrod,
- [System.Windows.Media.Colors]::DarkGoldenrod,
- [System.Windows.Media.Colors]::Goldenrod
- )
- $ColorsBlue = @(
- [System.Windows.Media.Colors]::AliceBlue,
- [System.Windows.Media.Colors]::LightCyan,
- [System.Windows.Media.Colors]::LightBlue,
- [System.Windows.Media.Colors]::LightSkyBlue,
- [System.Windows.Media.Colors]::SkyBlue,
- [System.Windows.Media.Colors]::DeepSkyBlue,
- [System.Windows.Media.Colors]::DodgerBlue,
- [System.Windows.Media.Colors]::CornflowerBlue,
- [System.Windows.Media.Colors]::RoyalBlue,
- [System.Windows.Media.Colors]::SteelBlue
- )
- $ColorsOrange = @(
- [System.Windows.Media.Colors]::FloralWhite,
- [System.Windows.Media.Colors]::Seashell,
- [System.Windows.Media.Colors]::Cornsilk,
- [System.Windows.Media.Colors]::Bisque,
- [System.Windows.Media.Colors]::NavajoWhite,
- [System.Windows.Media.Colors]::Wheat,
- [System.Windows.Media.Colors]::Orange,
- [System.Windows.Media.Colors]::DarkOrange,
- [System.Windows.Media.Colors]::Coral,
- [System.Windows.Media.Colors]::DarkSalmon
- )
- $ColorsRainbow = @(
- [System.Windows.Media.Colors]::LightPink,
- [System.Windows.Media.Colors]::Gold,
- [System.Windows.Media.Colors]::LightGreen,
- [System.Windows.Media.Colors]::LightBlue,
- [System.Windows.Media.Colors]::Lavender,
- [System.Windows.Media.Colors]::LightCyan,
- [System.Windows.Media.Colors]::LightYellow,
- [System.Windows.Media.Colors]::LightCoral,
- [System.Windows.Media.Colors]::Plum,
- [System.Windows.Media.Colors]::White
- )
- $ColorsPastel = @(
- [System.Windows.Media.Colors]::LavenderBlush,
- [System.Windows.Media.Colors]::LemonChiffon,
- [System.Windows.Media.Colors]::MintCream,
- [System.Windows.Media.Colors]::AliceBlue,
- [System.Windows.Media.Colors]::Honeydew,
- [System.Windows.Media.Colors]::Seashell,
- [System.Windows.Media.Colors]::Thistle,
- [System.Windows.Media.Colors]::LightCyan,
- [System.Windows.Media.Colors]::MistyRose,
- [System.Windows.Media.Colors]::Azure
- )
- $ColorsChristmas = @(
- [System.Windows.Media.Colors]::Gold,
- [System.Windows.Media.Colors]::Red,
- [System.Windows.Media.Colors]::ForestGreen,
- [System.Windows.Media.Colors]::White,
- [System.Windows.Media.Colors]::Silver,
- [System.Windows.Media.Colors]::Crimson,
- [System.Windows.Media.Colors]::DarkGreen,
- [System.Windows.Media.Colors]::Goldenrod,
- [System.Windows.Media.Colors]::LightCyan,
- [System.Windows.Media.Colors]::LightPink
- )
- #$player1 = New-Object System.Windows.Media.MediaPlayer
- #$player1.Open([Uri](Join-Path $SCRIPT_DIR $Music))
- #$player1.Volume = $MusVolume
- #$playerksm = New-Object System.Windows.Media.MediaPlayer
- #$playerksm.Open([Uri](Join-Path $SCRIPT_DIR "s.mp3"))
- #$playerksm.Volume = 0.7
- #$bgFile = Join-Path $SCRIPT_DIR "h.jpg"
- function DE { [System.Windows.Forms.Application]::DoEvents() }
- # function TypeKey {
- # $wav = Join-Path $SCRIPT_DIR 't.wav'
- # $key = New-Object System.Media.SoundPlayer $wav
- # $key.PlaySync()
- # }
- # function What {
- # $wav = Join-Path $SCRIPT_DIR "w.wav"
- # $key = New-Object System.Media.SoundPlayer $wav
- # $key.PlaySync()
- # }
- # $player1.Add_MediaEnded({
- # $player1.Position = [TimeSpan]::Zero
- # $player1.Play()
- # })
- [xml]$xaml = @"
- <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- Title="๐๐ โ"
- Height="680" Width="800"
- WindowStartupLocation="CenterScreen"
- ResizeMode="NoResize"
- WindowStyle="ToolWindow"
- Topmost="True"
- Background="Black">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="*"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
- <Canvas Name="MainCanvas" Grid.Row="0">
- <Canvas.Background>
- <!--ImageBrush ImageSource="$bgFile" Stretch="Fill"/-->
- </Canvas.Background>
- <TextBlock Name="s1" Text="*" FontSize="10" Foreground="White" Canvas.Left="30" Canvas.Top="2"/>
- <TextBlock Name="s2" Text="*" FontSize="8" Foreground="Pink" Canvas.Left="752" Canvas.Top="45"/>
- <TextBlock Name="s3" Text="*" FontSize="4" Foreground="LightCyan" Canvas.Left="40" Canvas.Top="50"/>
- <TextBlock Name="s4" Text="*" FontSize="6" Foreground="LightCyan" Canvas.Left="10" Canvas.Top="40"/>
- <TextBlock Name="s5" Text="*" FontSize="9" Foreground="LightCyan" Canvas.Left="520" Canvas.Top="25"/>
- <TextBlock Name="s6" Text="*" FontSize="7" Foreground="Yellow" Canvas.Left="20" Canvas.Top="80"/>
- <TextBlock Name="s7" Text="*" FontSize="5" Foreground="White" Canvas.Left="600" Canvas.Top="60"/>
- <TextBlock Name="s8" Text="." FontSize="18" Foreground="White" Canvas.Left="50" Canvas.Top="10"/>
- <TextBlock Name="s9" Text="." FontSize="22" Foreground="Pink" Canvas.Left="452" Canvas.Top="65"/>
- <TextBlock Name="s10" Text="." FontSize="12" Foreground="LightCyan" Canvas.Left="340" Canvas.Top="30"/>
- <TextBlock Name="s11" Text="." FontSize="16" Foreground="LightCyan" Canvas.Left="100" Canvas.Top="15"/>
- <TextBlock Name="s12" Text="." FontSize="10" Foreground="LightCyan" Canvas.Left="150" Canvas.Top="5"/>
- <TextBlock Name="s13" Text="." FontSize="8" Foreground="Yellow" Canvas.Left="720" Canvas.Top="100"/>
- <TextBlock Name="s14" Text="." FontSize="20" Foreground="White" Canvas.Left="260" Canvas.Top="18"/>
- <TextBlock Name="SnowTest" Canvas.Left="18" Canvas.Top="15" FontFamily="Lucida Console"
- FontSize="14" Foreground="Lime" Text=""/>
- <TextBlock Name="FPS" Canvas.Left="15" Canvas.Top="45" FontFamily="Lucida Console"
- FontSize="14" Foreground="Cyan" Text=""/>
- <Canvas Name="FireCanvas" Top="0" Left="0"
- Width="800" Height="600"
- Panel.ZIndex="99"
- IsHitTestVisible="False"/>
- </Canvas>
- <Border Grid.Row="1" Background="#1A1A1A" BorderBrush="Gold" BorderThickness="2" Margin="5">
- <StackPanel Orientation="Vertical" Margin="10">
- <TextBlock Text="๐งช FIREWORK PHYSICS LAB"
- Foreground="Gold"
- FontSize="14"
- FontWeight="Bold"
- HorizontalAlignment="Center"
- Margin="0,0,0,10"/>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="*"/>
- </Grid.ColumnDefinitions>
- <StackPanel Grid.Column="0" Margin="10,0">
- <TextBlock Text="Gravity: 1"
- Name="GravityValue"
- Foreground="LightCyan"
- FontSize="12"
- HorizontalAlignment="Center"/>
- <Slider Name="GravitySlider"
- Minimum="-2.0"
- Maximum="5.0"
- Value="1"
- TickFrequency="0.1"
- TickPlacement="BottomRight"
- Foreground="Cyan"
- Margin="5,0"
- ToolTip="Gravity force. Press G(+) or Shift-G(-) to fine tune">
- <Slider.Resources>
- <Style TargetType="Thumb">
- <Setter Property="Background" Value="Cyan"/>
- <Setter Property="Height" Value="15"/>
- <Setter Property="Width" Value="15"/>
- </Style>
- <Style TargetType="TickBar">
- <Setter Property="Fill" Value="LightGray"/>
- </Style>
- </Slider.Resources>
- </Slider>
- <TextBlock Text="๐ฝ Gravity force (+/- G/Shift G)"
- Foreground="White"
- FontSize="11"
- HorizontalAlignment="Center"/>
- </StackPanel>
- <StackPanel Grid.Column="1" Margin="10,0">
- <TextBlock Text="Explosion force: 15"
- Name="ForceValue"
- Foreground="LightCoral"
- FontSize="12"
- HorizontalAlignment="Center"/>
- <Slider Name="ForceSlider"
- Minimum="1"
- Maximum="2000"
- Value="10"
- TickFrequency="1"
- TickPlacement="BottomRight"
- Foreground="OrangeRed"
- Margin="5,0"
- ToolTip="Explosion force. Press E(+) or Shift-E(-) to fine tune">
- <Slider.Resources>
- <Style TargetType="Thumb">
- <Setter Property="Background" Value="OrangeRed"/>
- <Setter Property="Height" Value="15"/>
- <Setter Property="Width" Value="15"/>
- </Style>
- </Slider.Resources>
- </Slider>
- <TextBlock Text="๐ฅ Explosion force (+/- E/Shift E)"
- Foreground="White"
- FontSize="11"
- HorizontalAlignment="Center"/>
- </StackPanel>
- <StackPanel Grid.Column="2" Margin="10,0">
- <TextBlock Text="Drag coefficient: $script:AirResistance"
- Name="AirResistanceValue"
- Foreground="LightGreen"
- FontSize="12"
- HorizontalAlignment="Center"/>
- <Slider Name="AirResistanceSlider"
- Minimum="-0.002"
- Maximum="5"
- Value="$script:AirResistance"
- TickFrequency="0.001"
- TickPlacement="BottomRight"
- Foreground="LimeGreen"
- Margin="5,0"
- ToolTip="Drag coefficient. Press D(+) or Shift D(-) to fine tune">
- <Slider.Resources>
- <Style TargetType="Thumb">
- <Setter Property="Background" Value="LimeGreen"/>
- <Setter Property="Height" Value="15"/>
- <Setter Property="Width" Value="15"/>
- </Style>
- </Slider.Resources>
- </Slider>
- <TextBlock Text="๐ฌ๏ธ Drag coefficient (+/- D/Shift D)"
- Foreground="White"
- FontSize="11"
- HorizontalAlignment="Center"/>
- </StackPanel>
- </Grid>
- <Button Name="ResetButton"
- Content="๐ Reset"
- Width="200"
- Height="30"
- Background="#333333"
- Foreground="White"
- BorderBrush="Gray"
- Margin="0,10,0,5"
- HorizontalAlignment="Center"
- ToolTip="Reset"/>
- <Border Background="#222222" CornerRadius="5" Margin="0,5" Padding="5">
- <TextBlock Name="CurrentPhysicsLabel"
- Text="โ๏ธ Actual: G=0.50, E=15.0, C=$script:AirResistance"
- Foreground="LightGray"
- FontSize="12"
- HorizontalAlignment="Center"/>
- </Border>
- </StackPanel>
- </Border>
- </Grid>
- </Window>
- "@
- function Get-DragDescription {
- param([double]$dragValue)
- $dragRanges = @(
- @{ Max = -0.0000000001; Description = "Vacuum (+ dark energy)" }
- @{ Max = 0.00005; Description = "Interstellar medium" }
- @{ Max = 0.001; Description = "Moon exosphere" }
- @{ Max = 0.002; Description = "Pluto / Charon exosphere" }
- @{ Max = 0.003; Description = "Io plasma torus (tenuous)" }
- @{ Max = 0.004; Description = "Thin COโ, early Mars" }
- @{ Max = 0.006; Description = "Triton nitrogen geysers" }
- @{ Max = 0.010; Description = "Mars atmosphere (present)" }
- @{ Max = 0.015; Description = "Earth atmosphere" }
- @{ Max = 0.04; Description = "Uranus/Neptune upper haze" }
- @{ Max = 0.08; Description = "Gas giant upper clouds (Jupiter)" }
- @{ Max = 0.12; Description = "Saturn cloud tops" }
- @{ Max = 0.15; Description = "Titan atmosphere" }
- @{ Max = 0.3; Description = "Deep Jovian atmosphere (pressure)" }
- @{ Max = 0.5; Description = "Venus upper clouds" }
- @{ Max = 0.8; Description = "Venus lower atmosphere" }
- @{ Max = 1.5; Description = "Water (Earthsea level)" }
- @{ Max = 2.0; Description = "Cryogenic fluid (Liquid methane sea)" }
- @{ Max = 2.5; Description = "Mercury (liquid metal)" }
- @{ Max = 3.0; Description = "Europa sub-surface ocean (salty)" }
- @{ Max = 3.5; Description = "Molten metal" }
- @{ Max = 4.0; Description = "Molten iron / Planetary core material" }
- @{ Max = 4.5; Description = "Hot tar / Bitumen" }
- @{ Max = 5.0; Description = "Honey ๐/ Ultra-dense fluid" }
- )
- foreach ($range in $dragRanges) {
- if ($dragValue -le $range.Max) {
- return $range.Description
- }
- }
- return "Unknown Medium"
- }
- function Get-GravityDescription {
- param([double]$gravityValue)
- $gravityRanges = @(
- @{ Max = -2.0; Description = "Alcubierre drive field (exotic matter core)" }
- @{ Max = -1.5; Description = "Exotic matter strong repulsion" }
- @{ Max = -1.0; Description = "Negative energy density bubble" }
- @{ Max = -0.5; Description = "Static wormhole throat repulsion" }
- @{ Max = -0.1; Description = "Quantum foam negative mass fluctuation" }
- @{ Max = 0.0; Description = "Zero-G / Orbit" }
- @{ Max = 0.1; Description = "Asteroid / Deimos" }
- @{ Max = 0.15; Description = "Moon (Luna)" }
- @{ Max = 0.35; Description = "Mars" }
- @{ Max = 0.9; Description = "Venus, similar to Earth" }
- @{ Max = 1.0; Description = "Earth, sea level, standard)" }
- @{ Max = 1.1; Description = "Wolf 1069 b, Earth-mass exoplanet" }
- @{ Max = 1.5; Description = "Kepler-296f, Super-Earth candidate" }
- @{ Max = 2.0; Description = "HD 40307 g, massive Super-Earth candidate" }
- @{ Max = 2.5; Description = "Gliese 667 Cc, dense iron Super-Earth" }
- @{ Max = 3.0; Description = "Neptune-like" }
- @{ Max = 4.0; Description = "Uranus-like" }
- @{ Max = 5.0; Description = "Gas giant (Jupiter-like)" }
- )
- foreach ($range in $gravityRanges) {
- if ($gravityValue -le $range.Max) {
- return $range.Description
- }
- }
- return "Unknown "
- }
- function Get-YieldDescription {
- param([double]$yieldValue)
- $yieldRanges = @(
- @{ Max = 1.4; Description = "Tiny firecracker" }
- @{ Max = 2.2; Description = "String firecracker" }
- @{ Max = 3.2; Description = "Large firecracker (M-80)" }
- @{ Max = 3.9; Description = "โญ LARGE FIREWORK (~20g TNT)" }
- @{ Max = 4.5; Description = "Very large firework shell" }
- @{ Max = 5.5; Description = "Stun grenade (Flashbang)" }
- @{ Max = 7.1; Description = "Hand grenade (M67)" }
- @{ Max = 8.9; Description = "RPG-7 warhead" }
- @{ Max = 10.0; Description = "40mm grenade (HEDP)" }
- @{ Max = 12.2; Description = "60mm mortar shell" }
- @{ Max = 15.0; Description = "120mm mortar shell" }
- @{ Max = 18.7; Description = "Anti-tank mine" }
- @{ Max = 22.4; Description = "500lb bomb (WWII)" }
- @{ Max = 27.4; Description = "'Daisy Cutter' (BLU-82)" }
- @{ Max = 33.2; Description = "1000lb bomb (JDAM)" }
- @{ Max = 41.2; Description = "2000lb bomb (GBU-31)" }
- @{ Max = 45; Description = "Major truck bomb" }
- )
- foreach ($range in $yieldRanges) {
- if ([Math]::Sqrt($yieldValue) -le $range.Max) {
- return $range.Description
- }
- }
- return "No idea"
- }
- function New-SparkShape {
- param($color, $size)
- $shapeType = Get-Random -Minimum 0 -Maximum 4
- switch ($shapeType) {
- 0 {
- $rect = New-Object System.Windows.Shapes.Rectangle
- $rect.Width = $size * 1.5
- $rect.Height = $size * 1.5
- $rect.Fill = New-Object System.Windows.Media.SolidColorBrush $color
- $rect
- }
- 1 {
- $points = New-Object System.Windows.Media.PointCollection
- $points.Add([System.Windows.Point]::new($size, 0))
- $points.Add([System.Windows.Point]::new($size * 2, $size))
- $points.Add([System.Windows.Point]::new($size, $size * 2))
- $points.Add([System.Windows.Point]::new(0, $size))
- $polygon = New-Object System.Windows.Shapes.Polygon
- $polygon.Points = $points
- $polygon.Fill = New-Object System.Windows.Media.SolidColorBrush $color
- $polygon.Stroke = New-Object System.Windows.Media.SolidColorBrush $color
- $polygon.StrokeThickness = 0.5
- $polygon.Width = $size * 2
- $polygon.Height = $size * 2
- $polygon
- }
- 2 {
- $geometry = New-Object System.Windows.Media.GeometryGroup
- $verticalRect = New-Object System.Windows.Media.RectangleGeometry
- $verticalRect.Rect = [System.Windows.Rect]::new($size * 0.7, 0, $size * 0.6, $size * 2)
- $horizontalRect = New-Object System.Windows.Media.RectangleGeometry
- $horizontalRect.Rect = [System.Windows.Rect]::new(0, $size * 0.7, $size * 2, $size * 0.6)
- $geometry.Children.Add($verticalRect)
- $geometry.Children.Add($horizontalRect)
- $path = New-Object System.Windows.Shapes.Path
- $path.Data = $geometry
- $path.Fill = New-Object System.Windows.Media.SolidColorBrush $color
- $path.Width = $size * 2
- $path.Height = $size * 2
- $path
- }
- 3 {
- $geometry = New-Object System.Windows.Media.GeometryGroup
- $pathGeometry1 = New-Object System.Windows.Media.PathGeometry
- $figure1 = New-Object System.Windows.Media.PathFigure
- $figure1.StartPoint = [System.Windows.Point]::new(0, 0)
- $figure1.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size, $size * 2), $true))
- $figure1.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size * 2, 0), $true))
- $figure1.IsClosed = $true
- $pathGeometry1.Figures.Add($figure1)
- $pathGeometry2 = New-Object System.Windows.Media.PathGeometry
- $figure2 = New-Object System.Windows.Media.PathFigure
- $figure2.StartPoint = [System.Windows.Point]::new(0, $size * 2)
- $figure2.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size, 0), $true))
- $figure2.Segments.Add([System.Windows.Media.LineSegment]::new([System.Windows.Point]::new($size * 2, $size * 2), $true))
- $figure2.IsClosed = $true
- $pathGeometry2.Figures.Add($figure2)
- $geometry.Children.Add($pathGeometry1)
- $geometry.Children.Add($pathGeometry2)
- $path = New-Object System.Windows.Shapes.Path
- $path.Data = $geometry
- $path.Fill = New-Object System.Windows.Media.SolidColorBrush $color
- $path.Width = $size * 2
- $path.Height = $size * 2
- $path
- }
- }
- }
- function Sort-AllColorPalettes {
- function Get-ColorBrightness($Color) {
- return (0.3 * $Color.R + 0.4 * $Color.G + 0.3 * $Color.B) / 255.0
- }
- $palettePairs = @(
- @{Name = "ColorsRed"; Value = $ColorsRed }
- @{Name = "ColorsPurple"; Value = $ColorsPurple }
- @{Name = "ColorsGreen"; Value = $ColorsGreen }
- @{Name = "ColorsYellow"; Value = $ColorsYellow }
- @{Name = "ColorsBlue"; Value = $ColorsBlue }
- @{Name = "ColorsOrange"; Value = $ColorsOrange }
- @{Name = "ColorsRainbow"; Value = $ColorsRainbow }
- @{Name = "ColorsPastel"; Value = $ColorsPastel }
- @{Name = "ColorsChristmas"; Value = $ColorsChristmas }
- )
- foreach ($pair in $palettePairs) {
- $sorted = $pair.Value | Sort-Object { Get-ColorBrightness $_ } -Descending
- Set-Variable -Scope Script -Name $pair.Name -Value $sorted
- }
- }
- function Add-TwinkleColorsToPalettes {
- foreach ($paletteName in @("ColorsRed", "ColorsPurple", "ColorsGreen", "ColorsYellow",
- "ColorsBlue", "ColorsOrange", "ColorsRainbow", "ColorsPastel", "ColorsChristmas")) {
- $palette = Get-Variable -Name $paletteName -ValueOnly
- $twinkleColors = @()
- foreach ($color in $palette) {
- $twinkle1 = [System.Windows.Media.Color]::FromRgb(
- [Math]::Min(255, $color.R + 70),
- [Math]::Min(255, $color.G + 70),
- [Math]::Min(255, $color.B + 70)
- )
- $twinkle2 = [System.Windows.Media.Color]::FromRgb(
- [Math]::Min(255, $color.R + 100),
- [Math]::Min(255, $color.G + 100),
- [Math]::Min(255, $color.B + 100)
- )
- $twinkleColors += $twinkle1, $twinkle2
- }
- $extendedPalette = $twinkleColors + $palette
- Set-Variable -Scope Script -Name $paletteName -Value $extendedPalette
- }
- }
- Sort-AllColorPalettes
- Add-TwinkleColorsToPalettes
- function Get-ColorPalette {
- param(
- [int]$MinColors = 3,
- [int]$MaxColors = 10,
- [switch]$RandomSize = $true,
- [switch]$Sorted = $true
- )
- $palettes = @($ColorsRed, $ColorsPurple, $ColorsGreen, $ColorsYellow,
- $ColorsBlue, $ColorsOrange, $ColorsRainbow, $ColorsPastel, $ColorsChristmas)
- $selectedPalette = $palettes[(Get-Random -Minimum 0 -Maximum $palettes.Count)]
- if ($RandomSize) {
- $paletteSize = Get-Random -Minimum $MinColors -Maximum $MaxColors
- } else {
- $paletteSize = $MaxColors
- }
- if ($paletteSize -lt $selectedPalette.Count) {
- $startIndex = Get-Random -Minimum 0 -Maximum ($selectedPalette.Count - $paletteSize)
- $palette = $selectedPalette[$startIndex..($startIndex + $paletteSize - 1)]
- } else {
- $palette = $selectedPalette[0..($paletteSize - 1)]
- }
- return $palette
- }
- function Apply-BlastToSnowflakes {
- param($blastX, $blastY, $blastPower = 40)
- $airDensity = [Math]::Max(0.001, $script:AirResistance)
- $baseRadius = 250
- $blastRadius = $baseRadius / (1 + $airDensity * 5)
- $baseForce = $blastPower * 0.5
- $maxForce = $baseForce / (1 + $airDensity * 8)
- foreach ($flake in $snowflakes) {
- $dx = $flake.X - $blastX
- $dy = $flake.Y - $blastY
- $distance = [Math]::Sqrt($dx * $dx + $dy * $dy)
- if ($distance -lt $blastRadius -and $distance -gt 3) {
- $dirX = $dx / $distance
- $dirY = $dy / $distance
- $distanceFactor = 1.0 / ($distance * 0.08)
- $force = $maxForce * $distanceFactor
- $force = [Math]::Min($force, $maxForce * 1.5)
- $massFactor = 1.0 / ($flake.Mass + 0.3)
- $flake.VX += $dirX * $force * $massFactor * 0.015
- $flake.VY += $dirY * $force * $massFactor * 0.015
- $turbulence = 1.0 / (1 + $airDensity * 4)
- $flake.VX += (Get-Random -Minimum -$turbulence -Maximum $turbulence) * 0.005
- $flake.VY += (Get-Random -Minimum -$turbulence -Maximum $turbulence) * 0.005
- $rotationEffect = 1.0 / (1 + $airDensity * 2)
- $flake.RotationSpeed += (Get-Random -Minimum -4 -Maximum 4) * $rotationEffect
- }
- }
- }
- function New-Firework {
- param($x, $y)
- $PIXEL_SCALE = 2.0
- $halfPhysicsScale = 0.5 * $script:PHYSICS_SCALE
- $baseExplosionForce = $script:ExplosionForce * $script:PHYSICS_SCALE
- $dragFactor = $script:AirResistance * 0.8
- $viscosity = 1.0 + ($dragFactor * 3.0)
- $tanhArg = ($dragFactor - 0.015) * 20
- $adjustment = 1.0 + (0.3 * [Math]::Tanh($tanhArg))
- $mediumDamping = 1.0 / (1.0 + ($viscosity * $dragFactor * $adjustment))
- $effectiveExplosionForce = $baseExplosionForce * $mediumDamping
- $fireworkPalette = Get-ColorPalette
- $paletteSize = $fireworkPalette.Count
- $BlastForceForSnow = $script:ExplosionForce * 10
- Apply-BlastToSnowflakes $x $y $BlastForceForSnow
- $randomSparkCount = Get-Random -Minimum 0 -Maximum 15
- $nSparks = [math]::Round(25 + $randomSparkCount)
- $avgForcePerSpark = $effectiveExplosionForce / [Math]::Max(1, $nSparks)
- $rng = New-Object System.Random
- $SPEED_SCALE_FACTOR = 2000
- $speedLimitFactor = 1.0 / (1.0 + ($script:AirResistance * 2.0))
- Apply-BlastToSnowflakes
- for ($i = 0; $i -lt $nSparks; $i++) {
- $baseSize = $rng.Next(1, 5)
- $angle = $rng.NextDouble() * 360.0
- $radians = $angle * [Math]::PI / 180.0
- $mass = $baseSize * $halfPhysicsScale
- $forceShare = 0.7 + ($rng.NextDouble() * 0.6)
- $sparkForce = $avgForcePerSpark * $forceShare
- $baseSpeed = ($sparkForce * $SPEED_SCALE_FACTOR) / $mass
- $sizeDragEffect = 1.0 / [Math]::Sqrt($baseSize)
- $massInertiaEffect = [Math]::Sqrt($mass / 50)
- $initialSpeed = $baseSpeed * $sizeDragEffect * $massInertiaEffect
- $randomMultiplier = 0.8 + ($rng.NextDouble() * 0.4)
- $initialSpeed = $initialSpeed * $randomMultiplier
- $targetSpeed = $initialSpeed * $speedLimitFactor
- $finalRandom = 0.9 + ($rng.NextDouble() * 0.2 * (1.0 + $script:AirResistance))
- $initialSpeed = $targetSpeed * $finalRandom
- if ($script:AirResistance -gt 1.0) {
- $angleNoise = ($rng.NextDouble() - 0.5) * 25.0 * $script:AirResistance
- $radians += $angleNoise * [Math]::PI / 180.0
- }
- $maxStartIndex = [Math]::Min(2, $paletteSize - 1)
- $startColorIndex = $rng.Next(0, $maxStartIndex + 1)
- $currentColorIndex = $startColorIndex
- $startColor = $fireworkPalette[$startColorIndex]
- $shape = New-SparkShape -color $startColor -size $baseSize
- if ($shape -eq $null) { continue }
- $halfWidth = $shape.Width / 2
- $halfHeight = $shape.Height / 2
- $shapePosX = $x - $halfWidth
- $shapePosY = $y - $halfHeight
- $fireCanvas.Children.Add($shape) | Out-Null
- [System.Windows.Controls.Canvas]::SetLeft($shape, $shapePosX)
- [System.Windows.Controls.Canvas]::SetTop($shape, $shapePosY)
- $cosAngle = [Math]::Cos($radians)
- $sinAngle = [Math]::Sin($radians)
- $velocityX = $cosAngle * $initialSpeed
- $velocityY = $sinAngle * $initialSpeed
- $spark = [PSCustomObject]@{
- Shape = $shape
- X = $x
- Y = $y
- VX = $velocityX
- VY = $velocityY
- Opacity = 1
- BaseSize = $baseSize
- CurrentSize = $baseSize
- Rotation = $rng.Next(0, 360)
- RotationSpeed = $rng.Next(-15, 15)
- Mass = $mass
- PhysicsScale = $script:PHYSICS_SCALE
- LifeTime = $rng.Next(40, 100)
- Age = 0
- CurrentColorIndex = $currentColorIndex
- StartColorIndex = $startColorIndex
- ColorChangeCounter = 0
- ColorChangeSpeed = $rng.Next(3, 8)
- ShapeType = $shape.GetType().Name
- MediumDamping = $mediumDamping
- DarkenOverTime = $true
- ShouldTwinkle = $rng.NextDouble() -lt 0.3
- TwinkleIntensity = $rng.NextDouble() * 0.2 + 0.1
- TwinkleFrequency = $rng.Next(5, 15)
- TwinkleCounter = 0
- ColorPalette = $fireworkPalette
- StartInTwinkleZone = $rng.NextDouble() -lt 0.5
- IsTwinkling = $false
- TwinklePhase = 0
- }
- $activeSparks.Add($spark)
- }
- $soundIndex = Get-Random -Minimum 0 -Maximum 3
- $volume = 0.8 + $script:ExplosionForce / 100
- $adjustedVolume = $volume * $mediumDamping
- #$boom = New-Object System.Windows.Media.MediaPlayer
- # Register-ObjectEvent -InputObject $boom -EventName MediaEnded -Action {
- # $boom = $EventArgs.Source
- # $boom.Close()
- # $boom = $null
- # } | Out-Null
- # switch ($soundIndex) {
- # 0 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "a.wav")) }
- # 1 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "b.wav")) }
- # 2 { $boom.Open([Uri](Join-Path $SCRIPT_DIR "c.wav")) }
- # }
- # $boom.Volume = [Math]::Max(0.1, [Math]::Min(1.0, $adjustedVolume))
- # $boom.Play()
- }
- $reader = New-Object System.Xml.XmlNodeReader $xaml
- $window = [Windows.Markup.XamlReader]::Load($reader)
- $snowtest = $window.FindName("SnowTest")
- $fpstext = $window.FindName("FPS")
- $fireCanvas = $window.FindName("FireCanvas")
- $canvas = $window.FindName("MainCanvas")
- $window.Add_MouseLeftButtonDown({
- $pos = $_.GetPosition($fireCanvas)
- New-Firework $pos.X $pos.Y
- })
- function UpdatePhysicsLabel {
- $label = $window.FindName("CurrentPhysicsLabel")
- $roundDragCoeff = [math]::Round($script:AirResistance,3)
- $descDensity = Get-DragDescription $roundDragCoeff
- $roundGravity = [math]::Round($script:Gravity*2,1)
- $descGravity = Get-GravityDescription $roundGravity
- $roundYield = [math]::Round($script:ExplosionForce,1)
- $descYield = Get-YieldDescription $roundYield
- $label.Text = "โ๏ธ Current: G($descGravity)=$roundGravity, E($descYield)=$roundYield, D($descDensity)=$roundDragCoeff"
- $script:SNOW_AIR_DRAG_SCALED = $script:AirResistance * $script:PHYSICS_SCALE / 50
- $script:SNOW_GRAVITY_SCALED = $script:Gravity * $script:SNOW_GRAVITY_SCALE / 5
- $script:AIR_RESISTANCE_ABS = [Math]::Abs($airResistance)
- $script:DARK_ENERGY_FORCE = $script:AIR_RESISTANCE_ABS * 10 * $deltaTime
- }
- $window.Add_KeyDown({
- param($sender, $e)
- switch ($e.Key) {
- 'G' {
- $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -0.01 } else { 0.01 }
- $slider = $window.FindName("GravitySlider")
- $script:Gravity = ([math]::Max($slider.Minimum, [math]::Min($slider.Maximum,$slider.Value + $delta)))/2
- $slider.Value = $script:Gravity*2
- UpdatePhysicsLabel
- }
- 'E' {
- $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -1 } else { 1 }
- $slider = $window.FindName("ForceSlider")
- $script:ExplosionForce = [math]::Max($slider.Minimum, [math]::Min($slider.Maximum, $script:ExplosionForce + $delta))
- $slider.Value = $script:ExplosionForce
- UpdatePhysicsLabel
- }
- 'D' {
- $delta = if ($e.KeyboardDevice.Modifiers -band 'Shift') { -0.001 } else { 0.001 }
- $slider = $window.FindName("AirResistanceSlider")
- $script:AirResistance = [math]::Max($slider.Minimum, [math]::Min($slider.Maximum, $script:AirResistance + $delta))
- $slider.Value = $script:AirResistance
- UpdatePhysicsLabel
- }
- }
- $e.Handled = $true
- })
- UpdatePhysicsLabel
- $gravitySlider = $window.FindName("GravitySlider")
- $forceSlider = $window.FindName("ForceSlider")
- $airSlider = $window.FindName("AirResistanceSlider")
- $gravitySlider.Add_ValueChanged({
- $value = [math]::Round($this.Value, 2)
- $window.FindName("GravityValue").Text = "Gravity: $value"
- $script:Gravity = $value/2
- UpdatePhysicsLabel
- })
- $forceSlider.Add_ValueChanged({
- $value = [math]::Round($this.Value, 1)
- $window.FindName("ForceValue").Text = "Explosion size: $value"
- $script:ExplosionForce = $value
- UpdatePhysicsLabel
- })
- $airSlider.Add_ValueChanged({
- $value = [math]::Round($this.Value, 3)
- $window.FindName("AirResistanceValue").Text = "Drag Coefficient: $value"
- $script:AirResistance = $value
- UpdatePhysicsLabel
- })
- $window.FindName("ResetButton").Add_Click({
- $script:Gravity = 0.5
- $script:ExplosionForce = 15
- $script:AirResistance = 0.015
- $window.FindName("GravitySlider").Value = 1
- $window.FindName("ForceSlider").Value = 15
- $window.FindName("AirResistanceSlider").Value = 0.015
- UpdatePhysicsLabel
- })
- UpdatePhysicsLabel
- $shapes = "A","B","C","D"
- $flakes = for ($i = 1; $i -le 50; $i++) {
- @{
- Name = "fl$i"
- X = Get-Random -Min 0 -Max 800
- Y = Get-Random -Min -30 -Max 630
- Shape = Get-Random $shapes
- }
- }
- $snowflakes = @()
- $SNOWFLAKE_SHAPES = @{
- A = "M10,0 L10.5,1.5 L12,1 L11,3 L13,4 L11,5 L12,7 L10,6 L8,7 L9,5 L7,4 L9,3 L8,1 L9.5,1.5 Z"
- B = "M10,0 L11,3 L14,4 L11,5 L12,8 L10,6 L8,8 L9,5 L6,4 L9,3 Z"
- C = "M10,0 L12,6 L18,6 L13,10 L15,16 L10,12 L5,16 L7,10 L2,6 L8,6 Z"
- D = "M11,0 L13,4 L16,5 L13,7 L14,10 L11,7 L8,10 L9,7 L6,5 L9,4 L11,0 Z"
- }
- foreach ($f in $flakes) {
- $flake = [PSCustomObject]@{
- Shape = $null
- X = $f.X
- Y = $f.Y
- Mass = 0.15
- VY = 0
- VX = 0
- Rotation = 0
- RotationSpeed = (Get-Random -Minimum -2 -Maximum 2)
- Size = (Get-Random -Minimum 0.8 -Maximum 1.2)
- LifeTime = 0
- Wind = (Get-Random -Minimum -0.5 -Maximum 0.5)
- MaxLifeTime = 1200
- IsActive = $true
- }
- $flake.VY = $script:AirResistance * $script:SNOW_AIRDRAG_SCALE
- $p = New-Object System.Windows.Shapes.Path
- $p.Name = $f.Name
- $p.Fill = [System.Windows.Media.Brushes]::White
- $p.Stroke = [System.Windows.Media.Brushes]::LightBlue
- $p.StrokeThickness = 1
- $p.Data = [System.Windows.Media.Geometry]::Parse($SNOWFLAKE_SHAPES[$f.Shape])
- $p.Opacity = (Get-Random -Minimum 0.3 -Maximum 0.5)
- $scale = New-Object System.Windows.Media.ScaleTransform
- $scale.ScaleX = $flake.Size
- $scale.ScaleY = $flake.Size
- $p.RenderTransform = $scale
- $flake.Shape = $p
- $snowflakes += $flake
- [System.Windows.Controls.Canvas]::SetLeft($p, $flake.X)
- [System.Windows.Controls.Canvas]::SetTop($p, $flake.Y)
- $canvas.Children.Add($p) | Out-Null
- }
- $activeSparks = New-Object System.Collections.Generic.List[PSCustomObject]
- $activeBlastWaves = New-Object System.Collections.ArrayList
- $snowTimer = New-Object System.Windows.Threading.DispatcherTimer
- $snowTimer.Interval = [System.TimeSpan]::FromMilliseconds(60)
- $snowTimer.Add_Tick({
- $gravity = $script:SNOW_GRAVITY_SCALED
- $airResistance = $script:SNOW_AIR_DRAG_SCALED
- $windStrength = 0.3
- $airResistanceAbs = [Math]::Abs($airResistance)
- #$oCount = ($flakes.Count+$activeSparks.Count)
- #$fpstext.Text = "Objects count: $oCount"
- $deltaTime = $script:deltaTime
- $windFrequency = 50.0
- $windAmplitude = 0.3
- $centerX = 400
- $centerY = 300
- $darkEnergyForce = $script:DARK_ENERGY_FORCE
- $rotationDampFactor = 0.2
- $canvasWidth = $canvas.ActualWidth
- $resetMinY = -10
- $resetMaxY = 610
- $resetMaxYP20 = $resetMaxY+20
- $resetMinYM20 = $resetMinY-20
- $resetOpacityMin = 0.7
- $resetOpacityMax = 1.0
- $resetWindMin = -0.3
- $resetWindMax = 0.3
- $resetVXDamping = 0.7
- $resetFlakeDamping = 0.8 - [Math]::Min($airResistanceAbs * 0.1, 0.5)
- foreach ($flake in $snowflakes) {
- if (-not $flake.IsActive) { continue }
- $flake.LifeTime++
- $mass = $flake.Mass
- $forceY = $gravity * $mass
- $windVariation = 1 + [Math]::Sin($flake.LifeTime / $windFrequency) * $windAmplitude
- $currentWind = $flake.Wind * $windStrength * $windVariation
- $forceX = $currentWind * $mass
- $vx = $flake.VX
- $vy = $flake.VY
- $speed = [Math]::Sqrt($vx * $vx + $vy * $vy)
- if ($speed -gt 0) {
- $dragForce = $airResistance * $speed
- $dragEffect = $dragForce * (1.0 / $speed) * 0.1
- $flake.VX -= $dragEffect * $vx
- $flake.VY -= $dragEffect * $vy
- }
- if ($airResistance -gt 0.0001) {
- $terminalVelocity = ($gravity * $mass) / $airResistance
- if ([Math]::Abs($terminalVelocity) -gt $script:maxSnowSpeed) {
- $terminalVelocity = [Math]::Sign($terminalVelocity) * $script:maxSnowSpeed
- }
- } else {
- $terminalVelocity = 0
- }
- $fvy=$flake.VY
- if ([Math]::Sign($flake.VY) -eq [Math]::Sign($gravity) -and
- [Math]::Abs($flake.VY) -gt [Math]::Abs($terminalVelocity)) {
- $flake.VY = $terminalVelocity
- }
- $flake.VX += $forceX
- $flake.VY += $forceY
- if ($airResistance -lt 0) {
- $vecX = $flake.X - $centerX
- $vecY = $flake.Y - $centerY
- $distanceSquared = $vecX * $vecX + $vecY * $vecY
- if ($distanceSquared -lt 0.01) {
- $distanceSquared = 0.01
- }
- $distance = [Math]::Sqrt($distanceSquared)
- $distanceInverse = 1.0 / $distance
- $dirX = $vecX * $distanceInverse
- $dirY = $vecY * $distanceInverse
- $flake.VX += $dirX * $darkEnergyForce
- $flake.VY += $dirY * $darkEnergyForce
- }
- $flake.X += $flake.VX
- $flake.Y += $flake.VY
- $rotationDamping = 1.0 - [Math]::Min($airResistanceAbs * $rotationDampFactor, 0.8)
- $flake.Rotation += $flake.RotationSpeed * $rotationDamping * $deltaTime
- $flake.RotationSpeed *= $rotationDamping
- if ($flake.X -lt -20) {
- $flake.X = 820
- $flake.VX = [Math]::Abs($flake.VX) * $resetVXDamping
- }
- elseif ($flake.X -gt 820) {
- $flake.X = -20
- $flake.VX = -[Math]::Abs($flake.VX) * $resetVXDamping
- }
- if ($flake.Y -le $resetMinYM20) {
- $flake.X = Get-Random -Minimum 0 -Maximum $canvasWidth
- $flake.Y = Get-Random -Minimum $resetMaxY -Maximum $resetMaxYP20
- $flake.VX *= $resetFlakeDamping
- $flake.VY *= $resetFlakeDamping
- $flake.LifeTime = 0
- $flake.Shape.Opacity = Get-Random -Minimum $resetOpacityMin -Maximum $resetOpacityMax
- $flake.Wind = Get-Random -Minimum $resetWindMin -Maximum $resetWindMax
- $flake.IsActive = $true
- }
- if ($flake.Y -gt $resetMaxYP20) {
- $flake.X = Get-Random -Minimum 0 -Maximum $canvasWidth
- $flake.Y = Get-Random -Minimum $resetMinYM20 -Maximum $resetMinY
- $flake.VX *= $resetFlakeDamping
- $flake.VY *= $resetFlakeDamping
- $flake.LifeTime = 0
- $flake.Shape.Opacity = Get-Random -Minimum $resetOpacityMin -Maximum $resetOpacityMax
- $flake.Wind = Get-Random -Minimum $resetWindMin -Maximum $resetWindMax
- $flake.IsActive = $true
- }
- [System.Windows.Controls.Canvas]::SetLeft($flake.Shape, $flake.X)
- [System.Windows.Controls.Canvas]::SetTop($flake.Shape, $flake.Y)
- $rotate = New-Object System.Windows.Media.RotateTransform
- $rotate.Angle = $flake.Rotation
- $flake.Shape.RenderTransform = $rotate
- if ((Get-Random) -lt 0.1) {
- $flake.Shape.Opacity = $flake.Shape.Opacity * (0.8 + (Get-Random -Minimum 0 -Maximum 20) / 100)
- }
- }
- })
- $updateTimer = New-Object System.Windows.Threading.DispatcherTimer
- $updateTimer.Interval = [TimeSpan]::FromMilliseconds(30)
- $updateTimer.Add_Tick({
- # $timeLeft = $player1.NaturalDuration.TimeSpan - $player1.Position
- # $minutes = [int]$timeLeft.TotalMinutes
- # $seconds = $timeLeft.Seconds
- # $ms = $timeLeft.Milliseconds
- # $timeText = "{0:D2}:{1:D2}.{2:D3}" -f $minutes, $seconds, $ms
- # $snowtest.Text = $timeText
- #$script:deltaTime = 1.0
- $currentGravity = $script:Gravity * $script:PHYSICS_SCALE / 10
- $airResistanceBase = 0.3 * ($script:AirResistance / 0.02)
- if ($script:AirResistance -gt 1.0) {
- $nonLinearFactor = [Math]::Sqrt($script:AirResistance)
- $currentAirResistance = 0.3 * $nonLinearFactor * 10
- } else {
- $currentAirResistance = $airResistanceBase
- }
- $deltaTime = $script:deltaTime #*1.0
- $deltaTimeDouble = $script:deltaTime*2.0
- $minSpeedThreshold = 2.0
- $physScaleTimes5 = $script:PHYSICS_SCALE * 5
- $speedNormalizationDivisor = $script:PHYSICS_SCALE * 50.0
- $positionScale = ($deltaTimeDouble) / $script:PHYSICS_SCALE
- foreach ($s in $activeSparks.ToArray()) {
- $s.Age++
- $mass = $s.Mass
- $massNormalized = $mass / $script:PHYSICS_SCALE
- $forceY = ($currentGravity * $mass) / $script:PHYSICS_SCALE
- $vx = $s.VX
- $vy = $s.VY
- $vxSquared = $vx * $vx
- $vySquared = $vy * $vy
- $speed = [Math]::Sqrt($vxSquared + $vySquared)
- $dragX = 0
- $dragY = 0
- if ($speed -gt 0.001) {
- $speedOverPhysScale = $speed / $script:PHYSICS_SCALE
- $speedOverPhysScaleTimes5 = $speed / $physScaleTimes5
- $minSpeedRatio = [Math]::Min($speedOverPhysScale, 1.0)
- $additionalFactor = 0.3 + [Math]::Min($speedOverPhysScaleTimes5, 2.0)
- $dragForce = $currentAirResistance * $speed * $minSpeedRatio * $additionalFactor
- $maxStoppingForce = $massNormalized * ($speed / $deltaTimeDouble)
- if ($dragForce -gt $maxStoppingForce) {
- $dragForce = $maxStoppingForce
- }
- if ($dragForce -lt 0) {
- $maxNegativeDrag = 0.5 * $speed * $massNormalized
- $dragForce = [Math]::Max($dragForce, -$maxNegativeDrag)
- }
- $dragX = (-$dragForce * $vx) / $speed
- $dragY = (-$dragForce * $vy) / $speed
- }
- $accelerationX = $dragX / $massNormalized
- $accelerationY = ($forceY + $dragY) / $massNormalized
- $s.VX += $accelerationX * $deltaTime
- $s.VY += $accelerationY * $deltaTime
- if ([Math]::Abs($s.VX) -lt $minSpeedThreshold) { $s.VX = 0 }
- if ([Math]::Abs($s.VY) -lt $minSpeedThreshold) { $s.VY = 0 }
- $s.X += $s.VX * $positionScale
- $s.Y += $s.VY * $positionScale
- $lifeRatio = $s.Age / $s.LifeTime
- $normalizedSpeed = [Math]::Min(1.0, ($speed / $speedNormalizationDivisor))
- $opacityCalc = 1 - ($lifeRatio * $lifeRatio) - ($normalizedSpeed * 0.1)
- if ($opacityCalc -gt 0) {
- $s.Opacity = [Math]::Max(0, $opacityCalc)
- } else {
- $s.Opacity = 0
- }
- $sizeReduction = $lifeRatio * 0.7 + ($normalizedSpeed * 0.1)
- $s.CurrentSize = [Math]::Max(0.1, $s.BaseSize * (1 - $sizeReduction))
- $rotationFactor = 1 - ($lifeRatio * 0.5) - ($normalizedSpeed * 0.2)
- $s.Rotation += $s.RotationSpeed * $rotationFactor
- $s.ColorChangeCounter++
- if ($s.ColorChangeCounter -ge $s.ColorChangeSpeed) {
- $s.ColorChangeCounter = 0
- $s.CurrentColorIndex = ($s.CurrentColorIndex + 1) % $s.ColorPalette.Count
- $newColor = $s.ColorPalette[$s.CurrentColorIndex]
- $brush = New-Object System.Windows.Media.SolidColorBrush $newColor
- if ($s.ShapeType -eq "Rectangle") {
- $s.Shape.Fill = $brush
- } elseif ($s.ShapeType -eq "Polygon") {
- $s.Shape.Fill = $brush
- if ($s.Shape.Points.Count -eq 4) {
- $s.Shape.Stroke = $brush
- }
- } elseif ($s.ShapeType -eq "Path") {
- $s.Shape.Fill = $brush
- }
- }
- if ($s.StartInTwinkleZone -and $s.Age -lt 10) {
- $s.IsTwinkling = $true
- $s.TwinklePhase = ($s.Age % 3)
- $s.CurrentColorIndex = $s.TwinklePhase
- } elseif ($s.IsTwinkling) {
- $s.IsTwinkling = $false
- $s.CurrentColorIndex = $twinkleColorCount + (Get-Random -Minimum 0 -Maximum 3)
- } else {
- if ($s.CurrentColorIndex -lt $s.ColorPalette.Count - 1) {
- $s.CurrentColorIndex++
- }
- }
- if ((Get-Random) -lt 0.02 -and $s.Age -gt 20 -and $s.Age -lt $s.LifeTime - 20) {
- $s.CurrentColorIndex = Get-Random -Minimum 0 -Maximum $twinkleColorCount
- }
- if ($s.Age -ge $s.LifeTime -or $s.Opacity -le 0.05 -or
- $s.CurrentSize -le 0.1 -or $s.Y -gt $fireCanvas.ActualHeight) {
- $fireCanvas.Children.Remove($s.Shape)
- $null = $activeSparks.Remove($s)
- $script:NumberOfObjects = $script:NumberOfObjects - 1
- continue
- }
- $s.Shape.Opacity = $s.Opacity
- $scale = $s.CurrentSize / $s.BaseSize
- $sizeScaled = $s.BaseSize * 2 * $scale
- $halfSizeScaled = $sizeScaled / 2
- $s.Shape.Width = $sizeScaled
- $s.Shape.Height = $sizeScaled
- $transform = New-Object System.Windows.Media.RotateTransform
- $transform.Angle = $s.Rotation
- $transform.CenterX = $halfSizeScaled
- $transform.CenterY = $halfSizeScaled
- $s.Shape.RenderTransform = $transform
- $nx = $s.X - $halfSizeScaled
- $ny = $s.Y - $halfSizeScaled
- $isValidX = -not ([double]::IsNaN($nx) -or [double]::IsInfinity($nx))
- $isValidY = -not ([double]::IsNaN($ny) -or [double]::IsInfinity($ny))
- if ($isValidX -and $isValidY) {
- [System.Windows.Controls.Canvas]::SetLeft($s.Shape, $nx)
- [System.Windows.Controls.Canvas]::SetTop($s.Shape, $ny)
- }
- }
- })
- $fireTimer = New-Object System.Windows.Threading.DispatcherTimer
- $fireTimer.Interval = [TimeSpan]::FromMilliseconds(300)
- $fireTimer.Add_Tick({
- if ((Get-Random -Minimum 0 -Maximum 3) -eq 0) {
- $fx = Get-Random -Minimum 0 -Maximum 800
- $fy = Get-Random -Minimum 0 -Maximum 300
- New-Firework $fx $fy
- }
- })
- $stars = 1..14 | ForEach-Object { $window.FindName("s$_") }
- $stars1 = $stars[1..7]
- $stars2 = $stars[8..14]
- $story1 = New-Object System.Windows.Media.Animation.Storyboard
- $story2 = New-Object System.Windows.Media.Animation.Storyboard
- foreach ($s in $stars1) {
- $ani = New-Object System.Windows.Media.Animation.DoubleAnimation
- $ani.From = 0
- $ani.To = 1
- $blink=[double](Get-Random -Minimum 70 -Maximum 140)/100
- $ani.Duration= [System.TimeSpan]::FromSeconds($blink)
- $ani.AutoReverse = $true
- $ani.RepeatBehavior =[System.Windows.Media.Animation.RepeatBehavior]::Forever
- [System.Windows.Media.Animation.Storyboard]::SetTarget($ani, $s)
- [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($ani,(New-Object System.Windows.PropertyPath "Opacity"))
- $story1.Children.Add($ani)
- }
- foreach ($s in $stars2) {
- $ani = New-Object System.Windows.Media.Animation.DoubleAnimation
- $ani.From = 0
- $ani.To = 1
- $blink=[double](Get-Random -Minimum 80 -Maximum 150)/100
- $ani.BeginTime = [System.TimeSpan]::FromSeconds(0.5)
- $ani.Duration = [System.TimeSpan]::FromSeconds($blink)
- $ani.AutoReverse= $true
- $ani.RepeatBehavior = [System.Windows.Media.Animation.RepeatBehavior]::Forever
- [System.Windows.Media.Animation.Storyboard]::SetTarget($ani,$s)
- [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($ani,(New-Object System.Windows.PropertyPath "Opacity"))
- $story2.Children.Add($ani)
- }
- $window.Add_Loaded({
- #Show-CmdIntroSimple
- $story1.Begin()
- $story2.Begin()
- })
- # if ($SkipIntro -ne 1) {
- # Show-CmdIntro
- # }
- # else
- # {
- # $player1.Play()
- # }
- $window.Add_Closed({
- # $player1.Stop()
- # $player1.Close()
- $updateTimer.Stop()
- $fireTimer.Stop()
- $snowTimer.Stop()
- })
- $snowTimer.Start()
- $updateTimer.Start()
- $fireTimer.Start()
- $window.ShowDialog() | Out-Null
Advertisement
Comments
-
- โญ Changelly Profit Exploit Documentation โญ
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=jzmlvmjsba
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment