From ad8a540af24cc32b106b04d2b8e32ecb9e42f88c Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Mon, 9 Aug 2021 12:13:20 +0200 Subject: [PATCH] Tweaked difficulty a bit more & transfered lives to next level. --- cmd/tins2021/appcontext.go | 4 ++++ level.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/tins2021/appcontext.go b/cmd/tins2021/appcontext.go index e6b334b..6a52174 100644 --- a/cmd/tins2021/appcontext.go +++ b/cmd/tins2021/appcontext.go @@ -23,9 +23,13 @@ func (app *appContext) Play(ctx ui.Context) { func (app *appContext) PlayNext(ctx ui.Context, controller *levelController) { difficulty := controller.Level.Difficulty score := controller.Level.Score + lives := controller.Level.Lives + level := tins2021.NewLevel() level.Randomize(difficulty+1, numberOfStars) level.Score = score + level.Lives = lives + controller.Play(level) } diff --git a/level.go b/level.go index fae2523..6f816b3 100644 --- a/level.go +++ b/level.go @@ -154,7 +154,7 @@ func (l *Level) Randomize(difficulty int, stars int) { l.Tiles[pos].Star = true stars-- } - hearts := 1 + (80-difficulty)*4/80 // [5..0] + hearts := 1 + (100-difficulty)/50 // [3..1] (only difficulty has 3 hearts) for hearts > 0 { i := rand.Intn(len(positions)) pos := positions[i] @@ -164,7 +164,7 @@ func (l *Level) Randomize(difficulty int, stars int) { l.Tiles[pos].Heart = true hearts-- } - monsters := 2 + (6 * difficulty / 100) + monsters := 2 + (8 * difficulty / 100) minRandomMonster := (100-difficulty)*80/100 + 10 // [90..10] minChaserMonster := (100-difficulty)*50/100 + 50 // [100..50] for monsters > 0 {