This repository has been archived by the owner on Feb 25, 2023. It is now read-only.
/
options.go
68 lines (54 loc) · 1.66 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2013-2018 Laurent Moussault. All rights reserved.
// Licensed under a simplified BSD license (see LICENSE file).
package cozely
import (
"errors"
"github.com/cozely/cozely/internal"
)
////////////////////////////////////////////////////////////////////////////////
// An Option represents a configuration option used to change some parameters of
// the framework: see Configure.
type Option = func() error
////////////////////////////////////////////////////////////////////////////////
// Configure the framework.
func Configure(c ...Option) error {
for _, f := range c {
err := f()
if err != nil {
return nil
}
}
return nil
}
////////////////////////////////////////////////////////////////////////////////
// Title sets the title of the game.
func Title(t string) Option {
return func() error {
internal.Title = t
if internal.Running {
internal.SetWindowTitle(internal.Title)
}
return nil
}
}
////////////////////////////////////////////////////////////////////////////////
// UpdateStep sets the time step between calls to Update.
func UpdateStep(t float64) Option {
return func() error {
internal.UpdateStep = t
return nil
}
}
////////////////////////////////////////////////////////////////////////////////
// Multisample activate multisampling for the game window. Note that this is
// currently incompatible with the pixel package.
func Multisample(s int32) Option {
return func() error {
if internal.Running {
return errors.New("cannot change window multisampling while running")
}
internal.Window.Multisample = s
return nil
}
}
////////////////////////////////////////////////////////////////////////////////