Czysci teraz ekran i lepiej to wyglada. Dziala juz w jako up ale nie ma limitu i sie skreszuje jak bedzie mialo wyjsc poza ekran, a wiec trzeba dodac limit i momozna zaimplementowac s

This commit is contained in:
knmarcin 2018-11-16 21:09:29 +01:00
parent ed85c1ca11
commit 373a8f0dbb
2 changed files with 11 additions and 4 deletions

BIN
Pong

Binary file not shown.

15
Pong.go
View File

@ -2,6 +2,8 @@ package main
import (
"fmt"
"os"
"os/exec"
)
var gameBoard [10][30]string
@ -9,6 +11,7 @@ var x, y int
var i, j int
var Player1 [10]string
var Player2 [10]string
var P1index int
var Ball [10][30]string
var BallDirection [10][30]string
var BallSpeed int
@ -36,11 +39,14 @@ func CreateBoard() {
}
func PrintBoard() {
c:=exec.Command("clear")
c.Stdout = os.Stdout
c.Run()
for i = 0; i < 10; i++ {
for j = 0; j < 30; j++ {
fmt.Printf("%s", gameBoard[i][j])
}
fmt.Printf("\n")
fmt.Print("\n")
}
}
@ -68,12 +74,13 @@ func SpawnPlayers() {
}
func Loop() {
i = 5
P1index=3
for GameOver == false {
fmt.Scanf("%s", &LastPressedKey)
if LastPressedKey == "w" {
gameBoard[2][0] = "|"
gameBoard[5][0] = " "
i=i-1
P1index--
gameBoard[P1index][0] = "|"
gameBoard[P1index + 3][0] = " "
PrintBoard()
}
}