Update play-pong.ps1

This commit is contained in:
Markus Fleschutz 2023-09-19 20:34:00 +02:00
parent 5b2a69b336
commit a217faecee

View File

@ -27,15 +27,15 @@ function DrawFooter {
} }
function DrawPaddle($y, $isLeft) { function DrawPaddle($y, $isLeft) {
if ($isLeft) { if ($isLeft) {
$x = 0 $x = 0
} else { } else {
$x = [System.Console]::WindowWidth - 1 $x = [System.Console]::WindowWidth - 1
} }
for ($i = 0; $i -lt 5; $i++) { for ($i = 0; $i -lt 5; $i++) {
[System.Console]::SetCursorPosition($x, $y + $i) [System.Console]::SetCursorPosition($x, $y + $i)
[System.Console]::Write("") [System.Console]::Write("")
} }
} }
function ClearPaddle($y, $isLeft) { function ClearPaddle($y, $isLeft) {
@ -83,7 +83,7 @@ function UpdateBall {
$nextX = $script:ball.X $nextX = $script:ball.X
} }
if ($nextX -lt 0) { if ($nextX -lt 0) {
$script:scorePlayer2++ $script:scorePlayer2++
DrawScores DrawScores
$nextX = [System.Console]::WindowWidth / 2 $nextX = [System.Console]::WindowWidth / 2