Consolodated config, added portals, etc.
This commit is contained in:
80
internal/config/config.go
Normal file
80
internal/config/config.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package config
|
||||
|
||||
import "image/color"
|
||||
|
||||
const (
|
||||
ScreenWidth = 960
|
||||
ScreenHeight = 540
|
||||
)
|
||||
|
||||
type GameConfig struct {
|
||||
Screen ScreenConfig
|
||||
Hero HeroConfig
|
||||
HUD HUDConfig
|
||||
Visual VisualConfig
|
||||
}
|
||||
|
||||
type ScreenConfig struct {
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
type HeroConfig struct {
|
||||
StartX float64
|
||||
StartY float64
|
||||
Radius float64
|
||||
Speed float64
|
||||
MaxStamina float64
|
||||
StaminaDrain float64
|
||||
StaminaRegen float64
|
||||
Color color.NRGBA
|
||||
}
|
||||
|
||||
type HUDConfig struct {
|
||||
X int
|
||||
Y int
|
||||
Margin int
|
||||
}
|
||||
|
||||
type VisualConfig struct {
|
||||
BackgroundColor color.NRGBA
|
||||
SaveNotificationColor color.NRGBA
|
||||
StaminaNormalColor color.NRGBA
|
||||
StaminaLowColor color.NRGBA
|
||||
FPSGoodColor color.NRGBA
|
||||
FPSWarnColor color.NRGBA
|
||||
FPSPoorColor color.NRGBA
|
||||
}
|
||||
|
||||
func Default() GameConfig {
|
||||
return GameConfig{
|
||||
Screen: ScreenConfig{
|
||||
Width: ScreenWidth,
|
||||
Height: ScreenHeight,
|
||||
},
|
||||
Hero: HeroConfig{
|
||||
StartX: ScreenWidth / 2,
|
||||
StartY: ScreenHeight / 2,
|
||||
Radius: 28.0,
|
||||
Speed: 180.0,
|
||||
MaxStamina: 100.0,
|
||||
StaminaDrain: 50.0,
|
||||
StaminaRegen: 30.0,
|
||||
Color: color.NRGBA{R: 210, G: 220, B: 255, A: 255},
|
||||
},
|
||||
HUD: HUDConfig{
|
||||
X: ScreenWidth - 220,
|
||||
Y: 20,
|
||||
Margin: 16,
|
||||
},
|
||||
Visual: VisualConfig{
|
||||
BackgroundColor: color.NRGBA{R: 135, G: 206, B: 235, A: 255},
|
||||
SaveNotificationColor: color.NRGBA{R: 50, G: 200, B: 50, A: 255},
|
||||
StaminaNormalColor: color.NRGBA{R: 0, G: 255, B: 180, A: 255},
|
||||
StaminaLowColor: color.NRGBA{R: 255, G: 60, B: 60, A: 255},
|
||||
FPSGoodColor: color.NRGBA{R: 120, G: 255, B: 120, A: 255},
|
||||
FPSWarnColor: color.NRGBA{R: 255, G: 210, B: 100, A: 255},
|
||||
FPSPoorColor: color.NRGBA{R: 255, G: 120, B: 120, A: 255},
|
||||
},
|
||||
}
|
||||
}
|
||||
60
internal/config/constants.go
Normal file
60
internal/config/constants.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package config
|
||||
|
||||
import "time"
|
||||
|
||||
// Animation speeds
|
||||
const (
|
||||
NormalAnimSpeed = 0.03
|
||||
IdleAnimSpeed = 0.1
|
||||
SprintAnimSpeed = 0.01
|
||||
JumpingAnimSpeed = 0.005
|
||||
)
|
||||
|
||||
// Physics
|
||||
const (
|
||||
Gravity = 1200.0
|
||||
JumpStrength = -450.0
|
||||
MaxFallSpeed = 800.0
|
||||
GroundFriction = 0.85
|
||||
AirFriction = 0.95
|
||||
)
|
||||
|
||||
// Gameplay
|
||||
const (
|
||||
SprintSpeedMultiplier = 1.8
|
||||
SprintRecoveryThreshold = 0.2
|
||||
ExhaustedThreshold = 0.2
|
||||
StaminaLowThreshold = 0.2
|
||||
)
|
||||
|
||||
// FPS Monitoring
|
||||
const (
|
||||
FPSWarnThreshold = 0.85
|
||||
FPSPoorThreshold = 0.6
|
||||
FPSSampleWindow = time.Second
|
||||
TargetTPS = 60
|
||||
)
|
||||
|
||||
// Sprite
|
||||
const (
|
||||
AnimFrameWrap = 4096
|
||||
HeroSpriteScale = 0.175
|
||||
FixedSpriteHeight = 329.0
|
||||
FixedSpriteWidth = 315.0
|
||||
)
|
||||
|
||||
// Notifications
|
||||
const (
|
||||
SaveNotificationDuration = 2 * time.Second
|
||||
)
|
||||
|
||||
// Portal
|
||||
const (
|
||||
PortalThickness = 20.0
|
||||
PortalTransitionCooldown = 0.5
|
||||
)
|
||||
|
||||
// World
|
||||
const (
|
||||
GroundHeight = 16.0
|
||||
)
|
||||
78
internal/config/factory.go
Normal file
78
internal/config/factory.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type MapConfig struct {
|
||||
ID string
|
||||
Number int
|
||||
GroundColor color.NRGBA
|
||||
BackgroundColor color.NRGBA
|
||||
}
|
||||
|
||||
func DefaultMap1() MapConfig {
|
||||
return MapConfig{
|
||||
ID: "map1",
|
||||
Number: 1,
|
||||
GroundColor: color.NRGBA{R: 34, G: 139, B: 34, A: 255},
|
||||
BackgroundColor: color.NRGBA{R: 135, G: 206, B: 235, A: 255},
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultMap2() MapConfig {
|
||||
return MapConfig{
|
||||
ID: "map2",
|
||||
Number: 2,
|
||||
GroundColor: color.NRGBA{R: 139, G: 69, B: 19, A: 255},
|
||||
BackgroundColor: color.NRGBA{R: 155, G: 196, B: 215, A: 255},
|
||||
}
|
||||
}
|
||||
|
||||
type PortalConfig struct {
|
||||
ID string
|
||||
DestinationMap string
|
||||
DestinationPortal string
|
||||
Color color.NRGBA
|
||||
GlowColor color.NRGBA
|
||||
}
|
||||
|
||||
func LeftPortalMap1() PortalConfig {
|
||||
return PortalConfig{
|
||||
ID: "map1_left",
|
||||
DestinationMap: "map2",
|
||||
DestinationPortal: "map2_right",
|
||||
Color: color.NRGBA{R: 255, G: 100, B: 100, A: 180},
|
||||
GlowColor: color.NRGBA{R: 255, G: 150, B: 150, A: 100},
|
||||
}
|
||||
}
|
||||
|
||||
func RightPortalMap1() PortalConfig {
|
||||
return PortalConfig{
|
||||
ID: "map1_right",
|
||||
DestinationMap: "map2",
|
||||
DestinationPortal: "map2_left",
|
||||
Color: color.NRGBA{R: 100, G: 255, B: 100, A: 180},
|
||||
GlowColor: color.NRGBA{R: 150, G: 255, B: 150, A: 100},
|
||||
}
|
||||
}
|
||||
|
||||
func LeftPortalMap2() PortalConfig {
|
||||
return PortalConfig{
|
||||
ID: "map2_left",
|
||||
DestinationMap: "map1",
|
||||
DestinationPortal: "map1_right",
|
||||
Color: color.NRGBA{R: 100, G: 255, B: 100, A: 180},
|
||||
GlowColor: color.NRGBA{R: 150, G: 255, B: 150, A: 100},
|
||||
}
|
||||
}
|
||||
|
||||
func RightPortalMap2() PortalConfig {
|
||||
return PortalConfig{
|
||||
ID: "map2_right",
|
||||
DestinationMap: "map1",
|
||||
DestinationPortal: "map1_left",
|
||||
Color: color.NRGBA{R: 255, G: 100, B: 100, A: 180},
|
||||
GlowColor: color.NRGBA{R: 255, G: 150, B: 150, A: 100},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user