From c9f5c691be27abcbadc166f225ff532c7b61e991 Mon Sep 17 00:00:00 2001 From: Tomas Doran Date: Sat, 24 Dec 2022 18:10:13 +0000 Subject: [PATCH] More colors --- render/color.go | 42 ++++++++++++++++++++++++++++++++++++++++++ render/sprite.go | 11 ----------- screen/initial.go | 12 ++++++------ screen/turnmenu.go | 12 ++++++------ 4 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 render/color.go diff --git a/render/color.go b/render/color.go new file mode 100644 index 0000000..1af61a2 --- /dev/null +++ b/render/color.go @@ -0,0 +1,42 @@ +package render + +import ( + "image/color" + + "github.com/faiface/pixel" +) + +func GetColor(r, g, b int) color.Color { + if r == 0 && g == 0 && b == 0 { + return pixel.RGB(1, 1, 1) + } + return pixel.RGB(float64(r)/255, float64(g)/255, float64(b)/255) +} + +func ColorWhite() color.Color { + return GetColor(255, 255, 255) +} + +func ColorRed() color.Color { + return GetColor(255, 0, 0) +} + +func ColorYellow() color.Color { + return GetColor(255, 255, 0) +} + +func ColorGreen() color.Color { + return GetColor(0, 255, 0) +} + +func ColorBlue() color.Color { + return GetColor(0, 0, 255) +} + +func ColorPurple() color.Color { + return GetColor(255, 0, 255) +} + +func ColorCyan() color.Color { + return GetColor(1, 255, 255) +} diff --git a/render/sprite.go b/render/sprite.go index 22e1824..ab79f8c 100644 --- a/render/sprite.go +++ b/render/sprite.go @@ -113,14 +113,3 @@ func (sd *SpriteDrawer) GetNewBatch() *pixel.Batch { batch.Clear() return batch } - -func GetColor(r, g, b int) color.Color { - if r == 0 && g == 0 && b == 0 { - return pixel.RGB(1, 1, 1) - } - return pixel.RGB(float64(r)/255, float64(g)/255, float64(b)/255) -} - -func ColorWhite() color.Color { - return GetColor(255, 255, 255) -} diff --git a/screen/initial.go b/screen/initial.go index 51cb4b2..6f76b82 100644 --- a/screen/initial.go +++ b/screen/initial.go @@ -20,10 +20,10 @@ func (screen *InitialScreen) Enter(ctx screeniface.GameCtx) { ss := ctx.GetSpriteSheet() ClearScreen(ss, win) td := TextDrawer(ss) - td.DrawText(" MAYHEM - Remake of Chaos", logical.V(0, 9), render.ColorWhite(), win) - td.DrawText(" By bobtfish", logical.V(0, 8), render.ColorWhite(), win) - td.DrawText("How many wizards?", logical.V(0, 6), render.ColorWhite(), win) - td.DrawText("(Press 2 to 8)", logical.V(0, 5), render.ColorWhite(), win) + td.DrawText(" MAYHEM - Remake of Chaos", logical.V(0, 9), render.ColorPurple(), win) + td.DrawText(" By bobtfish", logical.V(0, 8), render.ColorRed(), win) + td.DrawText("How many wizards?", logical.V(0, 6), render.ColorYellow(), win) + td.DrawText("(Press 2 to 8)", logical.V(0, 5), render.ColorGreen(), win) textBottom(" Press H for help", render.ColorWhite(), ss, win) } @@ -38,8 +38,8 @@ func (screen *InitialScreen) Step(ctx screeniface.GameCtx) screeniface.GameScree if c >= 2 && c <= 8 { td := TextDrawer(ss) td.DrawText(fmt.Sprintf("%d", c), logical.V(18, 6), render.ColorWhite(), win) - td.DrawText("Level of computer wizards?", logical.V(0, 3), render.ColorWhite(), win) - td.DrawText("(Press 1 to 8)", logical.V(0, 2), render.ColorWhite(), win) + td.DrawText("Level of computer wizards?", logical.V(0, 3), render.ColorYellow(), win) + td.DrawText("(Press 1 to 8)", logical.V(0, 2), render.ColorPurple(), win) textBottom("", render.ColorWhite(), ss, win) return &ComputerDifficultyScreen{WizardCount: c} } diff --git a/screen/turnmenu.go b/screen/turnmenu.go index a4ecc03..d0fa1d7 100644 --- a/screen/turnmenu.go +++ b/screen/turnmenu.go @@ -171,14 +171,14 @@ func (screen *TurnMenuScreen) Enter(ctx screeniface.GameCtx) { ss := ctx.GetSpriteSheet() ClearScreen(ss, win) fmt.Printf("index %d\n", screen.PlayerIdx) - textBottom(" Press Keys 1 to 4", render.ColorWhite(), ss, win) + textBottom(" Press Keys 1 to 4", render.ColorYellow(), ss, win) td := TextDrawer(ss) - td.DrawText(players[screen.PlayerIdx].Name, logical.V(3, 7), render.ColorWhite(), win) + td.DrawText(players[screen.PlayerIdx].Name, logical.V(3, 7), render.ColorYellow(), win) td.DrawText(lawRatingText(ctx.GetLawRating()), logical.V(3, 6), render.ColorWhite(), win) - td.DrawText("1. Examine Spells", logical.V(3, 5), render.ColorWhite(), win) - td.DrawText("2. Select Spell", logical.V(3, 4), render.ColorWhite(), win) - td.DrawText("3. Examine Board", logical.V(3, 3), render.ColorWhite(), win) - td.DrawText("4. Continue With Game", logical.V(3, 2), render.ColorWhite(), win) + td.DrawText("1. Examine Spells", logical.V(3, 5), render.ColorCyan(), win) + td.DrawText("2. Select Spell", logical.V(3, 4), render.ColorCyan(), win) + td.DrawText("3. Examine Board", logical.V(3, 3), render.ColorCyan(), win) + td.DrawText("4. Continue With Game", logical.V(3, 2), render.ColorCyan(), win) } func lawRatingText(r int) string {