From 27ad3cfd6901fc46ec585ec86491b40906dbd178 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Wed, 23 Jul 2014 10:24:48 +0200 Subject: [PATCH] add top score Tracks the maximum achieved score across multiple tries. --- autoload/flappyvird.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autoload/flappyvird.vim b/autoload/flappyvird.vim index 359b12b..11eb5ea 100644 --- a/autoload/flappyvird.vim +++ b/autoload/flappyvird.vim @@ -9,6 +9,8 @@ let s:STATE_FINISH = 3 let s:t_ve = &t_ve +let s:top_score = 0 + let s:seed = 0 function! s:srand(seed) abort let s:seed = a:seed @@ -87,7 +89,8 @@ function! s:loop() call s:srand(localtime()) - call setline(sh + 2, printf(" SCORE: %6d", 0)) + call setline(sh + 2, printf(" SCORE: %10d", 0)) + call setline(sh + 3, printf(" TOP SCORE: %6d", s:top_score)) let pause = 0 let retry = 0 @@ -137,7 +140,11 @@ function! s:loop() if getline(sh)[jx-2: jx-1] == '* ' let sc += 1 - call setline(sh + 2, printf(" SCORE: %6d", sc)) + call setline(sh + 2, printf(" SCORE: %10d", sc)) + if sc > s:top_score + let s:top_score = sc + call setline(sh + 3, printf(" TOP SCORE: %6d", s:top_score)) + endif endif endif