Skip to content

Commit

Permalink
More colors
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Dec 24, 2022
1 parent ccfb669 commit c9f5c69
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 23 deletions.
42 changes: 42 additions & 0 deletions render/color.go
Original file line number Diff line number Diff line change
@@ -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)
}
11 changes: 0 additions & 11 deletions render/sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
12 changes: 6 additions & 6 deletions screen/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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}
}
Expand Down
12 changes: 6 additions & 6 deletions screen/turnmenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c9f5c69

Please sign in to comment.