Skip to content

Commit

Permalink
Merge pull request #1 from obvionaoe/main
Browse files Browse the repository at this point in the history
Add WindowOption and RunWithOptions method to allow for extra configuration
  • Loading branch information
BigJk committed May 9, 2024
2 parents a3526f4 + d976f61 commit 7710fdc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crt.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type Window struct {
invalidateBuffer bool
}

type WindowOption func(window *Window)

// NewGame creates a new terminal game with the given dimensions and font faces.
func NewGame(width int, height int, fonts Fonts, tty io.Reader, adapter InputAdapter, defaultBg color.Color) (*Window, error) {
if defaultBg == nil {
Expand Down Expand Up @@ -631,6 +633,20 @@ func (g *Window) Run(title string) error {
return nil
}

func (g *Window) RunWithOptions(options ...WindowOption) error {
ebiten.SetWindowSize(int(float64(g.cellsWidth*g.cellWidth)/DeviceScale()), int(float64(g.cellsHeight*g.cellHeight)/DeviceScale()))

for _, opt := range options {
opt(g)
}

if err := ebiten.RunGame(g); err != nil {
return err
}

return nil
}

func (g *Window) Kill() {
SysKill()
}

0 comments on commit 7710fdc

Please sign in to comment.