Lighting experiments

This commit is contained in:
2025-12-16 00:44:52 -07:00
parent c70f85abe5
commit de5f47f47b
12 changed files with 664 additions and 17 deletions

View File

@@ -6,10 +6,10 @@ import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"github.com/atridad/LilGuy/internal/maps"
"github.com/atridad/LilGuy/internal/save"
"github.com/atridad/LilGuy/internal/screens"
"github.com/atridad/LilGuy/internal/ui/menu"
"github.com/atridad/LilGuy/internal/maps"
)
const (
@@ -105,6 +105,8 @@ type state struct {
fpsEnabled bool
fpsCap FPSCap
portalVisibility bool
raycastEnabled bool
raycastDebugMode bool
saveManager *save.Manager
lastAutoSave time.Time
@@ -123,6 +125,8 @@ func newState() *state {
fpsEnabled: false,
fpsCap: FPSCap60,
portalVisibility: false,
raycastEnabled: true,
raycastDebugMode: false,
lastAutoSave: now,
autoSaveInterval: 30 * time.Second,
}
@@ -165,16 +169,18 @@ func newState() *state {
// Initialize screens
s.splashScreen = screens.NewSplashScreen()
s.titleScreen = screens.NewTitleScreen()
s.gameplayScreen = screens.NewGameplayScreen(ScreenWidth, ScreenHeight, mapManager, &s.fpsEnabled, &s.portalVisibility)
s.gameplayScreen = screens.NewGameplayScreen(ScreenWidth, ScreenHeight, mapManager, &s.fpsEnabled, &s.portalVisibility, &s.raycastEnabled, &s.raycastDebugMode)
s.pauseMenu = menu.NewPauseMenu()
// Wire up settings references
s.titleScreen.SetFPSMonitor(&s.fpsEnabled)
s.titleScreen.SetFPSCap(&s.fpsCap)
s.titleScreen.SetPortalVisibility(&s.portalVisibility)
s.titleScreen.SetRaycastSettings(&s.raycastEnabled, &s.raycastDebugMode)
s.pauseMenu.SetFPSMonitor(&s.fpsEnabled)
s.pauseMenu.SetFPSCap(&s.fpsCap)
s.pauseMenu.SetPortalVisibility(&s.portalVisibility)
s.pauseMenu.SetRaycastSettings(&s.raycastEnabled, &s.raycastDebugMode)
if saveManager != nil {
s.titleScreen.SetHasSaveGame(saveManager.HasSavedGame())
@@ -282,6 +288,16 @@ func (g *Game) updatePlaying() error {
return nil
}
// Toggle raycasting with L key
if inpututil.IsKeyJustPressed(ebiten.KeyL) {
g.state.gameplayScreen.ToggleRaycast()
}
// Toggle raycasting debug mode with B key
if inpututil.IsKeyJustPressed(ebiten.KeyB) {
g.state.gameplayScreen.ToggleRaycastDebug()
}
now := time.Now()
delta := now.Sub(g.state.lastTick)
g.state.lastTick = now