rename settings to config
This commit is contained in:
@@ -11,14 +11,14 @@ type KeyMap struct {
|
|||||||
Action3 any
|
Action3 any
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScreenSettings struct {
|
type ScreenConfig struct {
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
Scale int
|
Scale int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Settings struct {
|
type Config struct {
|
||||||
Name string
|
Name string
|
||||||
Screen *ScreenSettings
|
Screen *ScreenConfig
|
||||||
KeyMap KeyMap
|
KeyMap KeyMap
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) WatchKeyPress() {
|
func (e *Engine) WatchKeyPress() {
|
||||||
values := reflect.ValueOf(e.Settings.KeyMap)
|
values := reflect.ValueOf(e.Config.KeyMap)
|
||||||
|
|
||||||
for i := 0; i < values.NumField(); i++ {
|
for i := 0; i < values.NumField(); i++ {
|
||||||
key := values.Field(i).Interface().(ebiten.Key)
|
key := values.Field(i).Interface().(ebiten.Key)
|
||||||
@@ -25,33 +25,33 @@ func (e *Engine) ClearKeyPresed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) UpPressed() bool {
|
func (e *Engine) UpPressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Up.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Up.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) DownPressed() bool {
|
func (e *Engine) DownPressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Down.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Down.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) RightPressed() bool {
|
func (e *Engine) RightPressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Right.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Right.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) LeftPressed() bool {
|
func (e *Engine) LeftPressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Left.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Left.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Action0Pressed() bool {
|
func (e *Engine) Action0Pressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Action0.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Action0.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Action1Pressed() bool {
|
func (e *Engine) Action1Pressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Action1.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Action1.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Action2Pressed() bool {
|
func (e *Engine) Action2Pressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Action2.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Action2.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Action3Pressed() bool {
|
func (e *Engine) Action3Pressed() bool {
|
||||||
return e.PressedKey == e.Settings.KeyMap.Action3.(ebiten.Key)
|
return e.PressedKey == e.Config.KeyMap.Action3.(ebiten.Key)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import (
|
|||||||
|
|
||||||
type Engine struct {
|
type Engine struct {
|
||||||
Domain konstructor.DomainInterface
|
Domain konstructor.DomainInterface
|
||||||
Settings *konstructor.Settings
|
Config *konstructor.Config
|
||||||
KContext *konstructor.KContext
|
KContext *konstructor.KContext
|
||||||
PressedKey ebiten.Key
|
PressedKey ebiten.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||||
return e.Settings.Screen.Width, e.Settings.Screen.Height
|
return e.Config.Screen.Width, e.Config.Screen.Height
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Update(screen *ebiten.Image) error {
|
func (e *Engine) Update(screen *ebiten.Image) error {
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ func (ew *EngineWrapper) Init(options konstructor.EngineArgs) {
|
|||||||
ew.Engine = Engine{
|
ew.Engine = Engine{
|
||||||
KContext: options.KContext,
|
KContext: options.KContext,
|
||||||
Domain: options.Domain,
|
Domain: options.Domain,
|
||||||
Settings: options.Settings,
|
Config: options.Config,
|
||||||
}
|
}
|
||||||
ebiten.SetWindowSize(options.Settings.Screen.Width, options.Settings.Screen.Height)
|
ebiten.SetWindowSize(options.Config.Screen.Width, options.Config.Screen.Height)
|
||||||
ebiten.SetWindowTitle(options.Settings.Name)
|
ebiten.SetWindowTitle(options.Config.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ew *EngineWrapper) Run() {
|
func (ew *EngineWrapper) Run() {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package konstructor
|
|||||||
type EngineArgs struct {
|
type EngineArgs struct {
|
||||||
Domain DomainInterface
|
Domain DomainInterface
|
||||||
KContext *KContext
|
KContext *KContext
|
||||||
Settings *Settings
|
Config *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type EngineWrapperInterface interface {
|
type EngineWrapperInterface interface {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package konstructor
|
|||||||
type Konstructor struct {
|
type Konstructor struct {
|
||||||
Domain DomainInterface
|
Domain DomainInterface
|
||||||
KContext *KContext
|
KContext *KContext
|
||||||
Settings *Settings
|
Config *Config
|
||||||
EngineWrapper EngineWrapperInterface
|
EngineWrapper EngineWrapperInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ func (k Konstructor) Init() {
|
|||||||
k.EngineWrapper.Init(EngineArgs{
|
k.EngineWrapper.Init(EngineArgs{
|
||||||
Domain: k.Domain,
|
Domain: k.Domain,
|
||||||
KContext: k.KContext,
|
KContext: k.KContext,
|
||||||
Settings: k.Settings,
|
Config: k.Config,
|
||||||
})
|
})
|
||||||
k.EngineWrapper.Run()
|
k.EngineWrapper.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -19,9 +19,9 @@ func main() {
|
|||||||
CurrentLevel: 0,
|
CurrentLevel: 0,
|
||||||
CurrentPlayground: 0,
|
CurrentPlayground: 0,
|
||||||
},
|
},
|
||||||
Settings: &konstructor.Settings{
|
Config: &konstructor.Config{
|
||||||
Name: "Game",
|
Name: "Game",
|
||||||
Screen: &konstructor.ScreenSettings{
|
Screen: &konstructor.ScreenConfig{
|
||||||
Width: 320,
|
Width: 320,
|
||||||
Height: 240,
|
Height: 240,
|
||||||
Scale: 2,
|
Scale: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user