goo/src/game.go

35 lines
936 B
Go
Raw Normal View History

2024-03-23 09:10:26 +01:00
package src
import (
2024-03-23 13:54:00 +01:00
"fmt"
2024-03-23 09:10:26 +01:00
. "git.danitheskunk.com/squishy/blooblib"
2024-03-23 13:54:00 +01:00
"git.danitheskunk.com/squishy/blooblib/color"
2024-03-23 09:10:26 +01:00
)
type Game struct {
gobanRenderer *GobanRenderer
boardState *BoardState
}
2024-03-23 13:54:00 +01:00
func (g *Game) Init(bloob *Bloob, settings *Settings) {
2024-03-23 09:10:26 +01:00
settings.Title = "Goo v0.0"
2024-03-23 13:54:00 +01:00
settings.TargetFps = 240
2024-03-23 09:10:26 +01:00
g.boardState = NewBoardState()
g.gobanRenderer = NewGobanRenderer(g.boardState)
2024-03-23 13:54:00 +01:00
g.boardState.Set(Vec2i{X: 3, Y: 3}, Black)
2024-03-23 09:10:26 +01:00
}
2024-03-23 13:54:00 +01:00
func (g *Game) Render(bloob *Bloob, screen *Image) {
mouseTilePos := DivScalar(bloob.MousePos, 16)
2024-03-23 09:10:26 +01:00
g.gobanRenderer.Render(screen)
2024-03-23 13:54:00 +01:00
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)
2024-03-23 09:10:26 +01:00
}
2024-03-23 13:54:00 +01:00
func (g *Game) Update(bloob *Bloob) {
2024-03-23 09:10:26 +01:00
}