From 3407a93586a7b6c67285c6fa6de86c8b2aeaa67e Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Mon, 11 May 2020 00:00:35 +0200 Subject: [PATCH] Added flower types. --- cmd/tins2020/res/textures.txt | 40 ++++++++++++------------- flower.go | 56 +++++++++++++++++++++++++++++++++-- game.go | 36 ++++++++++++++++++++++ terrainrenderer.go | 5 ++-- 4 files changed, 113 insertions(+), 24 deletions(-) diff --git a/cmd/tins2020/res/textures.txt b/cmd/tins2020/res/textures.txt index fb34beb..919220b 100644 --- a/cmd/tins2020/res/textures.txt +++ b/cmd/tins2020/res/textures.txt @@ -70,26 +70,26 @@ flower-anemone-2: images/flower_yellowC_NW.png flower-anemone-3: images/flower_yellowC_SW.png flower-anemone-4: images/flower_yellowC_SE.png -flower-red-c-disabled: images/flower_redC_NE_disabled.png -flower-red-c-1: images/flower_redC_NE.png -flower-red-c-2: images/flower_redC_NW.png -flower-red-c-3: images/flower_redC_SW.png -flower-red-c-4: images/flower_redC_SE.png +flower-loosestrife-disabled: images/flower_redC_NE_disabled.png +flower-loosestrife-1: images/flower_redC_NE.png +flower-loosestrife-2: images/flower_redC_NW.png +flower-loosestrife-3: images/flower_redC_SW.png +flower-loosestrife-4: images/flower_redC_SE.png -flower-red-a-disabled: images/flower_redA_NE_disabled.png -flower-red-a-1: images/flower_redA_NE.png -flower-red-a-2: images/flower_redA_NW.png -flower-red-a-3: images/flower_redA_SW.png -flower-red-a-4: images/flower_redA_SE.png +flower-tulip-disabled: images/flower_redA_NE_disabled.png +flower-tulip-1: images/flower_redA_NE.png +flower-tulip-2: images/flower_redA_NW.png +flower-tulip-3: images/flower_redA_SW.png +flower-tulip-4: images/flower_redA_SE.png -flower-purple-a-disabled: images/flower_purpleA_NE_disabled.png -flower-purple-a-1: images/flower_purpleA_NE.png -flower-purple-a-2: images/flower_purpleA_NW.png -flower-purple-a-3: images/flower_purpleA_SW.png -flower-purple-a-4: images/flower_purpleA_SE.png +flower-ajuga-disabled: images/flower_purpleA_NE_disabled.png +flower-ajuga-1: images/flower_purpleA_NE.png +flower-ajuga-2: images/flower_purpleA_NW.png +flower-ajuga-3: images/flower_purpleA_SW.png +flower-ajuga-4: images/flower_purpleA_SE.png -flower-purple-c-disabled: images/flower_purpleC_NE_disabled.png -flower-purple-c-1: images/flower_purpleC_NE.png -flower-purple-c-2: images/flower_purpleC_NW.png -flower-purple-c-3: images/flower_purpleC_SW.png -flower-purple-c-4: images/flower_purpleC_SE.png +flower-coneflower-disabled: images/flower_purpleC_NE_disabled.png +flower-coneflower-1: images/flower_purpleC_NE.png +flower-coneflower-2: images/flower_purpleC_NW.png +flower-coneflower-3: images/flower_purpleC_SW.png +flower-coneflower-4: images/flower_purpleC_SE.png diff --git a/flower.go b/flower.go index 057f065..5f190b0 100644 --- a/flower.go +++ b/flower.go @@ -38,10 +38,62 @@ func NewPoppyTraits() FlowerTraits { Spread: 0.0004, Life: 0.99993, Resistance: FlowerResistance{ - Cold: 0.5, + Cold: 0.7, Hot: 0.7, Dry: 0.5, - Wet: 0.7, + Wet: 0.5, + }, + } +} + +func NewLoosestrifeTraits() FlowerTraits { + return FlowerTraits{ + Spread: 0.0005, + Life: 0.99993, + Resistance: FlowerResistance{ + Cold: 0.7, + Hot: 0.6, + Dry: 0.5, + Wet: 0.8, + }, + } +} + +func NewTulipTraits() FlowerTraits { + return FlowerTraits{ + Spread: 0.0005, + Life: 0.99993, + Resistance: FlowerResistance{ + Cold: 0.8, + Hot: 0.6, + Dry: 0.5, + Wet: 0.8, + }, + } +} + +func NewConeflowerTraits() FlowerTraits { + return FlowerTraits{ + Spread: 0.0005, + Life: 0.99993, + Resistance: FlowerResistance{ + Cold: 0.7, + Hot: 0.8, + Dry: 0.9, + Wet: 0.5, + }, + } +} + +func NewAjugaTraits() FlowerTraits { + return FlowerTraits{ + Spread: 0.0007, + Life: 0.99991, + Resistance: FlowerResistance{ + Cold: 0.9, + Hot: 0.5, + Dry: 0.75, + Wet: 0.75, }, } } diff --git a/game.go b/game.go index f58bbb7..fbf5cb7 100644 --- a/game.go +++ b/game.go @@ -49,6 +49,42 @@ func NewGame() *Game { Traits: NewPoppyTraits(), Unlocked: true, }) + herbarium.Add("loosestrife", FlowerDescriptor{ + Name: "Loosestrife", + Description: "A simple flower that will spread in temperate and wet climates.", + IconTemplate: "flower-loosestrife-%s", + BuyPrice: 100, + SellPrice: 20, + Traits: NewLoosestrifeTraits(), + Unlocked: false, + }) + herbarium.Add("tulip", FlowerDescriptor{ + Name: "Tulip", + Description: "A lovely flower that prefers a bit humid and colder climates.", + IconTemplate: "flower-tulip-%s", + BuyPrice: 500, + SellPrice: 100, + Traits: NewTulipTraits(), + Unlocked: false, + }) + herbarium.Add("coneflower", FlowerDescriptor{ + Name: "Coneflower", + Description: "A beautifull flower that can withstand hotter climates.", + IconTemplate: "flower-coneflower-%s", + BuyPrice: 20000, + SellPrice: 5000, + Traits: NewConeflowerTraits(), + Unlocked: false, + }) + herbarium.Add("ajuga", FlowerDescriptor{ + Name: "Ajuga", + Description: "A flower that is resitant to cold climates and spreads very easily.", + IconTemplate: "flower-ajuga-%s", + BuyPrice: 100000, + SellPrice: 10000, + Traits: NewAjugaTraits(), + Unlocked: false, + }) return &Game{ Speed: GameSpeedNormal, Balance: 100, diff --git a/terrainrenderer.go b/terrainrenderer.go index f5cd3ce..ca68a3a 100644 --- a/terrainrenderer.go +++ b/terrainrenderer.go @@ -170,9 +170,10 @@ func (r *terrainRenderer) Render(ctx *Context) { toItemTexture := func(x, y int32) *Texture { variant := r.terrain.Variant.Value(x, y) - _, ok := r.terrain.Flowers[Pt(x, y)] + flower, ok := r.terrain.Flowers[Pt(x, y)] if ok { - return variantToTexture("flower-anemone-%d", variant) + desc, _ := r.game.Herbarium.Find(flower.ID) + return ctx.Textures.Texture(desc.IconTemplate.Variant(variantToInt(variant))) } temp := r.terrain.Temp.Value(x, y) humid := r.terrain.Humid.Value(x, y)