mirror of
https://github.com/BigJk/crt.git
synced 2026-02-06 02:36:55 +00:00
Merge pull request #1 from obvionaoe/main
Add WindowOption and RunWithOptions method to allow for extra configuration
This commit is contained in:
commit
7710fdc88d
16
crt.go
16
crt.go
@ -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 {
|
||||
@ -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()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user