Game/OnTick.ps1

if ($game.CurrentX -eq 0) {
    $game.CurrentX = Get-Random -Minimum 1 -Maximum ($game.Width - 20)
    $game.CurrentY = Get-Random -Minimum 1 -Maximum ($game.Height - 15)
}
$dealIncX = -3,0,3 | Get-Random
$dealIncY = -2,0,2 | Get-Random 
$newCards =
    @(foreach ($n in 0..1) {
        if (($game.CurrentX + 13) -gt $game.Width) {
            $game.xIncrement*=-1
        }
        if (($game.CurrentY + 14) -gt $game.Height) {
            $game.yIncrement*=-1
        }
        if ($game.CurrentX -le 1) {
            $game.CurrentX = 2
            $game.xIncrement *= -1
        }
        if ($game.CurrentY -le 1) {
            $game.CurrentY = 2
            $game.yIncrement *= -1
        }
        [PSCustomObject]@{
        PSTypeName='PowerArcade.PlayingCard'
        Number = 1..13 | Get-Random
        Suite = '♠','♣','♥','♦' | Get-Random
            X = $game.CurrentX
            Y = $game.CurrentY
        }
        $game.CurrentX+=$game.xIncrement #($n * $dealIncX)
        $game.CurrentY+=$game.yIncrement # ($n * $dealIncY)
    })


if ($game.CardsOnScreen.Count -gt $game.MaxPopulation) {
    $game.CardsOnScreen = @()
    Restart-Level
}
$game.CardsOnScreen+= $newCards

$newCards | Out-String -Width 1kb | Write-Host -NoNewline