Rebuild for testing

This commit is contained in:
sloumdrone 2019-10-20 14:45:39 -07:00
parent c3213ee979
commit 71a0aefa26
2 changed files with 9 additions and 9 deletions

18
main.go
View File

@ -52,17 +52,17 @@ func SetCharMode(on bool) {
func makeBg(p player) bg {
out := bg{0, "", 3, 77, 0, 5, p}
var line strings.Builder
line.WriteString("▒▒▒▒")
line.WriteString("####")
for i := 0; i < 72; i++ {
line.WriteString(" ")
}
line.WriteString("▒▒▒▒")
line.WriteString("####")
out.tunnel = line.String()
return out
}
func makePlayer() player {
return player{4, max_cols / 2, 0, "@"}
return player{4, max_cols / 2, 0, "!"}
}
func exit(code int) {
@ -162,6 +162,7 @@ func (b *bg) newRight() int {
}
func (b *bg) buildNextLine() string {
b.l = b.l + b.newLeft()
b.r = b.r + b.newRight()
if b.l < 4 {
@ -173,14 +174,14 @@ func (b *bg) buildNextLine() string {
var out strings.Builder
out.WriteString("\n")
out.WriteString(strings.Repeat("", b.l))
out.WriteString(strings.Repeat("#", b.l))
out.WriteString(strings.Repeat(" ", b.r - b.l))
out.WriteString(strings.Repeat("", max_cols - b.r))
out.WriteString(strings.Repeat("#", max_cols - b.r))
return out.String()
}
func (b *bg) collision() bool {
if []rune(b.tunnel)[b.pl.row * max_cols + b.pl.col + b.pl.row - 1] == '' {
if b.tunnel[b.pl.row * max_cols + b.pl.col + b.pl.row - 1] == '#' {
return true
}
return false
@ -189,10 +190,10 @@ func (b *bg) collision() bool {
func (b *bg) update() {
ln := b.buildNextLine()
var out strings.Builder
if len([]rune(b.tunnel)) <= max_len {
if len(b.tunnel) <= max_len {
out.WriteString(b.tunnel)
} else {
out.WriteString(string([]rune(b.tunnel)[max_cols + 1:]))
out.WriteString(b.tunnel[max_cols + 1:])
}
out.WriteString(ln)
b.tunnel = out.String()
@ -252,7 +253,6 @@ restart:
game.update()
game.draw()
if game.collision() {
time.Sleep(1 * time.Second)
fmt.Printf("\033[2J\033[10;%dHGame Over",max_cols/2-6)
fmt.Printf("\033[11;%dHDepth: %d ft.",max_cols/2-8, game.tick * 6)
fmt.Printf("\033[13;%dHR To Restart",max_cols/2-7)

BIN
plummet

Binary file not shown.