Skip to content

Commit

Permalink
client: Added a small size and used in the cient texts
Browse files Browse the repository at this point in the history
  • Loading branch information
xescugc committed Nov 12, 2023
1 parent 7490f15 commit b2e595f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/hud.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ func (hs *HUDStore) Draw(screen *ebiten.Image) {
cp := hs.game.Store.Players.GetCurrentPlayer()

if cp.Lives == 0 {
text.Draw(screen, "YOU LOST", normalFont, int(cs.W/2), int(cs.H/2), color.White)
text.Draw(screen, "YOU LOST", smallFont, int(cs.W/2), int(cs.H/2), color.White)
}

if cp.Winner {
text.Draw(screen, "YOU WON!", normalFont, int(cs.W/2), int(cs.H/2), color.White)
text.Draw(screen, "YOU WON!", smallFont, int(cs.W/2), int(cs.H/2), color.White)
}

op := &ebiten.DrawImageOptions{}
Expand Down Expand Up @@ -313,19 +313,19 @@ func (hs *HUDStore) Draw(screen *ebiten.Image) {

psit := hs.game.Store.Players.GetState().(store.PlayersState).IncomeTimer
players := hs.game.Store.Players.GetPlayers()
text.Draw(screen, fmt.Sprintf("Income Timer: %ds", psit), normalFont, 0, 0, color.White)
text.Draw(screen, fmt.Sprintf("Income Timer: %ds", psit), smallFont, 0, 0, color.White)
var pcount = 1
var sortedPlayers = make([]*store.Player, 0, 0)
for _, p := range players {
sortedPlayers = append(sortedPlayers, p)
}
sort.Slice(sortedPlayers, func(i, j int) bool { return sortedPlayers[i].LineID < sortedPlayers[j].LineID })
for _, p := range sortedPlayers {
text.Draw(screen, fmt.Sprintf("Name: %s, Lives: %d, Gold: %d, Income: %d", p.Name, p.Lives, p.Gold, p.Income), normalFont, 0, 15*pcount, color.White)
text.Draw(screen, fmt.Sprintf("Name: %s, Lives: %d, Gold: %d, Income: %d", p.Name, p.Lives, p.Gold, p.Income), smallFont, 0, 15*pcount, color.White)
pcount++
}
if verbose {
text.Draw(screen, fmt.Sprintffmt.Sprintf("(X: %d, Y: %d)", int(hst.LastCursorPosition.X+cs.X), int(hst.LastCursorPosition.Y+cs.Y)), normalFont, 0, 15*pcount, color.White)
text.Draw(screen, fmt.Sprintf("(X: %d, Y: %d)", int(hst.LastCursorPosition.X+cs.X), int(hst.LastCursorPosition.Y+cs.Y)), smallFont, 0, 15*pcount, color.White)
}
}

Expand Down
6 changes: 6 additions & 0 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
wsc *websocket.Conn

normalFont font.Face
smallFont font.Face
)

func init() {
Expand All @@ -54,6 +55,11 @@ func init() {
DPI: dpi,
Hinting: font.HintingVertical,
})
smallFont, err = opentype.NewFace(tt, &opentype.FaceOptions{
Size: 16,
DPI: dpi,
Hinting: font.HintingVertical,
})
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit b2e595f

Please sign in to comment.