From 5a3ca97d0a558cf13c99f4560948de749fee965e Mon Sep 17 00:00:00 2001 From: knmarcin Date: Sun, 18 Nov 2018 11:45:45 +0100 Subject: [PATCH] Poprawione formatowanie. Wciaz musze zaimplementowac "action key" --- Pong.go | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Pong.go b/Pong.go index 109e0d5..3ce6877 100644 --- a/Pong.go +++ b/Pong.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "fmt" "os" "os/exec" @@ -71,26 +72,28 @@ func Loop() { i = 5 P1index=3 for GameOver == false { - fmt.Scanf("%c", &LastPressedKey) - if LastPressedKey == 'w' { - if P1index != 0 { - P1index-- - gameBoard[P1index][0] = "|" - gameBoard[P1index + 3][0] = " " - PrintBoard() - } else { - PrintBoard() - } - } - if LastPressedKey=='s' { - if P1index!=7 { - gameBoard[P1index][0] = " " - P1index++ - gameBoard[P1index + 2][0] = "|" - PrintBoard() - } else { + fmt.Scanf("%c", &LastPressedKey) + if LastPressedKey == 'w' { + if P1index != 0 { + P1index-- + gameBoard[P1index][0] = "|" + gameBoard[P1index + 3][0] = " " + PrintBoard() + } else { PrintBoard() + } + } + if LastPressedKey=='s' { + if P1index!=7 { + gameBoard[P1index][0] = " " + P1index++ + gameBoard[P1index + 2][0] = "|" + PrintBoard() + } else { + PrintBoard() + } + } + if LastPressedKey=='r' { } } - } }