Fix space numbering
This commit is contained in:
parent
8741b6cb75
commit
fd914cb985
4 changed files with 15 additions and 16 deletions
|
@ -138,30 +138,25 @@ func (b *board) updateBackgroundImage() {
|
|||
innerW := float64(b.w) - b.horizontalBorderSize*2 // Outer board width (including frame)
|
||||
|
||||
// Table
|
||||
box := image.NewRGBA(image.Rect(0, 0, b.w, b.h))
|
||||
img := ebiten.NewImageFromImage(box)
|
||||
img.Fill(tableColor)
|
||||
b.backgroundImage = ebiten.NewImageFromImage(img)
|
||||
b.backgroundImage = ebiten.NewImage(b.w, b.h)
|
||||
b.backgroundImage.Fill(tableColor)
|
||||
|
||||
// Frame
|
||||
box = image.NewRGBA(image.Rect(0, 0, frameW, b.h))
|
||||
img = ebiten.NewImageFromImage(box)
|
||||
img := ebiten.NewImage(frameW, b.h)
|
||||
img.Fill(frameColor)
|
||||
b.op.GeoM.Reset()
|
||||
b.op.GeoM.Translate(float64(b.horizontalBorderSize-borderSize), 0)
|
||||
b.backgroundImage.DrawImage(img, b.op)
|
||||
|
||||
// Face
|
||||
box = image.NewRGBA(image.Rect(0, 0, int(innerW), b.h-int(b.verticalBorderSize*2)))
|
||||
img = ebiten.NewImageFromImage(box)
|
||||
img = ebiten.NewImage(int(innerW), b.h-int(b.verticalBorderSize*2))
|
||||
img.Fill(faceColor)
|
||||
b.op.GeoM.Reset()
|
||||
b.op.GeoM.Translate(float64(b.horizontalBorderSize), float64(b.verticalBorderSize))
|
||||
b.backgroundImage.DrawImage(img, b.op)
|
||||
|
||||
// Bar
|
||||
box = image.NewRGBA(image.Rect(0, 0, int(b.barWidth), b.h))
|
||||
img = ebiten.NewImageFromImage(box)
|
||||
img = ebiten.NewImage(int(b.barWidth), b.h)
|
||||
img.Fill(frameColor)
|
||||
b.op.GeoM.Reset()
|
||||
b.op.GeoM.Translate(float64((b.w/2)-int(b.barWidth/2)), 0)
|
||||
|
@ -261,13 +256,16 @@ func (b *board) updateBackgroundImage() {
|
|||
for space, r := range b.spaceRects {
|
||||
if space < 1 || space > 24 {
|
||||
continue
|
||||
} else if b.gameState.PlayerNumber == 1 {
|
||||
space = 24 - space + 1
|
||||
}
|
||||
|
||||
sp := strconv.Itoa(space)
|
||||
if space < 10 {
|
||||
sp = " " + sp
|
||||
}
|
||||
x := r[0] + r[2]/2 + int(b.horizontalBorderSize/2) + 4
|
||||
y := r[1] + 2
|
||||
y := 2
|
||||
if b.bottomRow(space) {
|
||||
y = b.h - int(b.verticalBorderSize) + 2
|
||||
}
|
||||
|
@ -571,7 +569,7 @@ func (b *board) draw(screen *ebiten.Image) {
|
|||
if b.gameState.Turn == 0 {
|
||||
if playerRoll != 0 {
|
||||
b.op.GeoM.Reset()
|
||||
b.op.GeoM.Translate(float64(b.x+((b.innerW/4)*3)-int(b.horizontalBorderSize)/2-diceSize/2), float64(b.y+(b.innerH/2))-(float64(diceSize)*1.4))
|
||||
b.op.GeoM.Translate(float64(b.x+((b.innerW/4)*3)+int(b.horizontalBorderSize)/2-diceSize/2), float64(b.y+(b.innerH/2))-(float64(diceSize)*1.4))
|
||||
screen.DrawImage(diceImage(playerRoll), b.op)
|
||||
}
|
||||
} else if b.gameState.Turn == b.gameState.PlayerNumber && b.gameState.Roll1 != 0 {
|
||||
|
@ -867,6 +865,7 @@ func (b *board) stackSpaceRect(space int, stack int) (x, y, w, h int) {
|
|||
func (b *board) ProcessState() {
|
||||
if b.lastPlayerNumber != b.gameState.PlayerNumber {
|
||||
b.setSpaceRects()
|
||||
b.updateBackgroundImage()
|
||||
}
|
||||
b.updateButtonRects()
|
||||
b.lastPlayerNumber = b.gameState.PlayerNumber
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/boxcars
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919065634-7b233c9c4afc
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919075547-1e7c6a1d0250
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.0
|
||||
code.rocketnine.space/tslocum/messeji v1.0.3
|
||||
github.com/hajimehoshi/ebiten/v2 v2.5.9
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,5 +1,5 @@
|
|||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919065634-7b233c9c4afc h1:tXMB9OlKou1vAc8etMx6GV8Xntcz4oG+PveFJzvTFoE=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919065634-7b233c9c4afc/go.mod h1:LS/m5Zq7/93dP8XJrLkL1T5ZTwtddkN8X9TyRrrdCkQ=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919075547-1e7c6a1d0250 h1:tnoJHTC8XrZEKW1Zb5GrmT4RYn3oKkern4Qu8427yNQ=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20230919075547-1e7c6a1d0250/go.mod h1:LS/m5Zq7/93dP8XJrLkL1T5ZTwtddkN8X9TyRrrdCkQ=
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.0 h1:/xs59UCuo+NGs89ABilARlowQnmIsjbNVjss57W5O7k=
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.0/go.mod h1:xYmBfho98sIbB+Gtf8SU5GDQD9HOSqOtZ64eZnlHmRI=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.3 h1:o0HqUckStFUFE2SkYrkzRHoAY7QT7cTsuRQ7JEmfw6w=
|
||||
|
|
2
main.go
2
main.go
|
@ -22,7 +22,7 @@ func main() {
|
|||
ebiten.SetWindowTitle("bgammon.org - Free Online Backgammon")
|
||||
ebiten.SetWindowSize(screenWidth, screenHeight)
|
||||
ebiten.SetWindowResizable(true)
|
||||
ebiten.SetFPSMode(ebiten.FPSModeVsyncOffMinimum)
|
||||
ebiten.SetFPSMode(ebiten.FPSModeVsyncOn)
|
||||
ebiten.SetMaxTPS(60)
|
||||
ebiten.SetRunnableOnUnfocused(true)
|
||||
ebiten.SetWindowClosingHandled(true)
|
||||
|
|
Loading…
Reference in a new issue