drawing hover stone
This commit is contained in:
parent
3cf9d57277
commit
2a063ebcd5
Binary file not shown.
Before Width: | Height: | Size: 334 B After Width: | Height: | Size: 324 B |
2
go.mod
2
go.mod
|
@ -8,6 +8,6 @@ require git.danitheskunk.com/squishy/blooblib v0.0.0-00010101000000-000000000000
|
|||
|
||||
require (
|
||||
github.com/askeladdk/aseprite v0.0.4 // indirect
|
||||
github.com/veandco/go-sdl2 v0.4.38 // indirect
|
||||
github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240323054118-79669ab74d94 // indirect
|
||||
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,8 +1,8 @@
|
|||
github.com/askeladdk/aseprite v0.0.4 h1:/k1VTiDkPORnrzonUUV5oXWwdHBoYjIIYJ1K/PupNMU=
|
||||
github.com/askeladdk/aseprite v0.0.4/go.mod h1:lVW4EwZ7lgQjeHp7MhYj1NII5a/yLYyvAo7COPIn3WY=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/veandco/go-sdl2 v0.4.38 h1:lx8syOA2ccXlgViYkQe2Kn/4xt+p9mdd1Qc/yYMrmSo=
|
||||
github.com/veandco/go-sdl2 v0.4.38/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
|
||||
github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240323054118-79669ab74d94 h1:7Ay2TWWqg2J4mqPj6vgbg9ib7OzO37szAnQ48MmdD/Y=
|
||||
github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240323054118-79669ab74d94/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
|
||||
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 h1:6R2FC06FonbXQ8pK11/PDFY6N6LWlf9KlzibaCapmqc=
|
||||
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
|
||||
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
|
|
|
@ -45,3 +45,16 @@ func (bs *BoardState) Clear() {
|
|||
func (bs *BoardState) Draw(target *Image) {
|
||||
target.DrawTilemap(bs.tilemap, Vec2i{X: 10 * 16, Y: 1 * 16})
|
||||
}
|
||||
|
||||
func (bs *BoardState) DrawHover(target *Image, pos Vec2i, player CellState) {
|
||||
if bs.Get(pos) == Empty {
|
||||
switch player {
|
||||
case Black:
|
||||
target.Draw(tilesStones[tileStoneBlackHalf], Vec2i{X: (10 + pos.X) * 16, Y: (1 + pos.Y) * 16})
|
||||
break
|
||||
case White:
|
||||
target.Draw(tilesStones[tileStoneWhiteHalf], Vec2i{X: (10 + pos.X) * 16, Y: (1 + pos.Y) * 16})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
20
src/game.go
20
src/game.go
|
@ -1,7 +1,9 @@
|
|||
package src
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "git.danitheskunk.com/squishy/blooblib"
|
||||
"git.danitheskunk.com/squishy/blooblib/color"
|
||||
)
|
||||
|
||||
type Game struct {
|
||||
|
@ -9,20 +11,24 @@ type Game struct {
|
|||
boardState *BoardState
|
||||
}
|
||||
|
||||
func (g *Game) Init(settings *Settings) {
|
||||
func (g *Game) Init(bloob *Bloob, settings *Settings) {
|
||||
settings.Title = "Goo v0.0"
|
||||
settings.TargetFps = 240
|
||||
g.boardState = NewBoardState()
|
||||
g.gobanRenderer = NewGobanRenderer(g.boardState)
|
||||
|
||||
g.boardState.Set(Vec2i{X:3,Y:3}, Black)
|
||||
g.boardState.Set(Vec2i{X: 3, Y: 3}, Black)
|
||||
}
|
||||
|
||||
func (g *Game) Render(screen *Image) {
|
||||
func (g *Game) Render(bloob *Bloob, screen *Image) {
|
||||
mouseTilePos := DivScalar(bloob.MousePos, 16)
|
||||
g.gobanRenderer.Render(screen)
|
||||
//screen.DrawTilemap(g.tilemap, Vec2i{})
|
||||
//screen.Render(g.tilemap.Tileset[2], Vec2i{X: 16 * 25, Y: 16 * 4})
|
||||
//screen.Render(g.tilemap.Tileset[1], Vec2i{X: 16 * 13, Y: 16 * 16})
|
||||
if mouseTilePos.X >= 10 && mouseTilePos.Y >= 1 && mouseTilePos.X < 29 && mouseTilePos.Y < 20 {
|
||||
tilePos := Sub(mouseTilePos, Vec2i{X: 10, Y: 1})
|
||||
g.boardState.DrawHover(screen, tilePos, Black)
|
||||
}
|
||||
screen.DrawText(fmt.Sprintf("%3d x %3d", bloob.MousePos.X, bloob.MousePos.Y), DefaultFont, Vec2i{10, 10}, color.White)
|
||||
}
|
||||
|
||||
func (g *Game) Update() {
|
||||
func (g *Game) Update(bloob *Bloob) {
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ const (
|
|||
tileRightOfBoard = 13
|
||||
tileBottomLeftOfBoard = 14
|
||||
tileTopRightOfBoard = 15
|
||||
tileStoneBlack = 0
|
||||
tileStoneWhite = 1
|
||||
tileStoneBlackHalf = 2
|
||||
tileStoneWhiteHalf = 3
|
||||
tileStoneBlack = 1
|
||||
tileStoneWhite = 2
|
||||
tileStoneBlackHalf = 3
|
||||
tileStoneWhiteHalf = 4
|
||||
)
|
||||
|
||||
var tilesGoban []*Image
|
||||
|
|
Loading…
Reference in New Issue