Fixing minor timing error

This commit is contained in:
sloumdrone 2019-10-20 20:33:13 -07:00
parent f644f0ab52
commit 795dee588c
1 changed files with 2 additions and 1 deletions

View File

@ -253,6 +253,7 @@ 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)
@ -266,7 +267,7 @@ restart:
}
}
newtime := time.Now().UnixNano() / 1000000
if dt := newtime - oldtime; dt < 60 && dt >= 0 {
if dt := newtime - oldtime; dt < 100 && dt >= 0 {
diff := time.Duration(100 - dt)
time.Sleep(diff * time.Millisecond)
}