From 7150d03d1614fd546cf08249033575296d4273ea Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 14 May 2020 12:59:11 +0200 Subject: [PATCH] Enabled the mouse for dialing digits. Changed intro/readme a bit (dig -> harvest). --- README.md | 4 ++-- intro.go | 4 ++-- research.go | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ecff9df..18bd770 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape. -Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money. +Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can harvest flowers again to collect more money. **Controls:** - - H: Selects shovel + - H: Selects harvest tool - R: Selects research - Spacebar: pauses game - 1: runs game at normal speed diff --git a/intro.go b/intro.go index cea2aae..a4dadba 100644 --- a/intro.go +++ b/intro.go @@ -10,9 +10,9 @@ func (i *Intro) Init(ctx *Context) error { i.welcome.Text = "Welcome to Botanim!\n\n" + "In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape.\n\n" + - "Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money.\n\n" + + "Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can harvest flowers again to collect more money.\n\n" + "Controls:\n" + - " - H: Selects shovel\n" + + " - H: Selects harvest tool\n" + " - R: Selects research\n" + " - Spacebar: pauses game\n" + " - 1: runs game at normal speed\n" + diff --git a/research.go b/research.go index a4d4312..9d0dd01 100644 --- a/research.go +++ b/research.go @@ -52,6 +52,10 @@ type Digit struct { highlight int } +func (d *Digit) Blink() { + d.highlight = 4 +} + func (d *Digit) Render(ctx *Context) { font := ctx.Fonts.Font("title") color := White @@ -61,10 +65,6 @@ func (d *Digit) Render(ctx *Context) { font.RenderCopyAlign(ctx.Renderer, d.Value, Pt(d.Bounds.X+d.Bounds.W/2, d.Bounds.Y+int32(font.Height())), color, TextAlignmentCenter) } -func (d *Digit) Blink() { - d.highlight = 4 -} - func (d *Digit) Tick() { if d.highlight > 0 { d.highlight-- @@ -80,10 +80,15 @@ func (r *Research) Init(ctx *Context) error { r.AddChild(&r.description) r.AddChild(&r.specialists) r.AddChild(&r.input) + r.description.Text = "Call a specialist to conduct research with." r.digits = make([]Digit, 10) for i := range r.digits { + j := i r.digits[i].Value = strconv.Itoa(i) + r.digits[i].OnLeftMouseButtonClick = func(*Context) { + r.userTyped(j) + } r.AddChild(&r.digits[i]) } @@ -135,6 +140,9 @@ func (r *Research) userTyped(i int) { } func (r *Research) Handle(ctx *Context, event sdl.Event) bool { + if r.Container.Handle(ctx, event) { + return true + } switch e := event.(type) { case *sdl.KeyboardEvent: if e.Type == sdl.KEYDOWN {