Fixed lighting
This commit is contained in:
@@ -10,8 +10,20 @@ import (
|
||||
|
||||
func CreateDesert(screenWidth, screenHeight float64) *Map {
|
||||
m := NewMap("desert", 2, "Desert", screenWidth, screenHeight)
|
||||
m.BackgroundColor = color.NRGBA{R: 15, G: 20, B: 40, A: 255} // Dark blue night sky
|
||||
m.TimeOfDay = Nighttime
|
||||
m.BackgroundColor = color.NRGBA{R: 15, G: 20, B: 40, A: 255}
|
||||
m.Lighting = LightConfig{
|
||||
AmbientBrightness: 0.1,
|
||||
Sources: []LightSource{
|
||||
{
|
||||
X: screenWidth - 80,
|
||||
Y: 80,
|
||||
Radius: 450,
|
||||
Color: color.RGBA{R: 200, G: 220, B: 255, A: 255},
|
||||
Intensity: 0.5,
|
||||
ShadowDarkness: 0.7,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// ground surface
|
||||
m.World.AddSurface(&world.Surface{
|
||||
|
||||
@@ -8,12 +8,18 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type TimeOfDay string
|
||||
type LightSource struct {
|
||||
X, Y float64
|
||||
Radius float64
|
||||
Color color.RGBA
|
||||
Intensity float64
|
||||
ShadowDarkness float64
|
||||
}
|
||||
|
||||
const (
|
||||
Daytime TimeOfDay = "day"
|
||||
Nighttime TimeOfDay = "night"
|
||||
)
|
||||
type LightConfig struct {
|
||||
AmbientBrightness float64
|
||||
Sources []LightSource
|
||||
}
|
||||
|
||||
type Map struct {
|
||||
ID string
|
||||
@@ -24,7 +30,7 @@ type Map struct {
|
||||
World *world.World
|
||||
Portals []*portal.Portal
|
||||
BackgroundColor color.NRGBA
|
||||
TimeOfDay TimeOfDay // Day or Night tag
|
||||
Lighting LightConfig
|
||||
|
||||
bakedImage *ebiten.Image
|
||||
}
|
||||
@@ -39,7 +45,10 @@ func NewMap(id string, number int, displayName string, width, height float64) *M
|
||||
World: world.NewWorld(),
|
||||
Portals: make([]*portal.Portal, 0),
|
||||
BackgroundColor: color.NRGBA{R: 135, G: 206, B: 235, A: 255},
|
||||
TimeOfDay: Daytime, // Default to daytime
|
||||
Lighting: LightConfig{
|
||||
AmbientBrightness: 1.0,
|
||||
Sources: []LightSource{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,19 @@ import (
|
||||
func CreatePlains(screenWidth, screenHeight float64) *Map {
|
||||
m := NewMap("plains", 1, "Plains", screenWidth, screenHeight)
|
||||
m.BackgroundColor = color.NRGBA{R: 135, G: 206, B: 235, A: 255}
|
||||
m.TimeOfDay = Daytime
|
||||
m.Lighting = LightConfig{
|
||||
AmbientBrightness: 0.3,
|
||||
Sources: []LightSource{
|
||||
{
|
||||
X: screenWidth - 80,
|
||||
Y: 80,
|
||||
Radius: 600,
|
||||
Color: color.RGBA{R: 255, G: 250, B: 220, A: 255},
|
||||
Intensity: 0.7,
|
||||
ShadowDarkness: 0.5,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// ground surface
|
||||
groundColor := color.NRGBA{R: 34, G: 139, B: 34, A: 255}
|
||||
|
||||
Reference in New Issue
Block a user