mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-18 02:16:23 -05:00
parent
b13175b070
commit
89b031d2b7
@ -32,7 +32,7 @@ type MapRenderer struct {
|
||||
}
|
||||
|
||||
// CreateMapRenderer creates a new MapRenderer, sets the required fields and returns a pointer to it.
|
||||
func CreateMapRenderer(renderer d2interface.Renderer, mapEngine *d2mapengine.MapEngine, term d2interface.Terminal) *MapRenderer {
|
||||
func CreateMapRenderer(renderer d2interface.Renderer, mapEngine *d2mapengine.MapEngine, term d2interface.Terminal, startX, startY float64) *MapRenderer {
|
||||
result := &MapRenderer{
|
||||
renderer: renderer,
|
||||
mapEngine: mapEngine,
|
||||
@ -40,7 +40,8 @@ func CreateMapRenderer(renderer d2interface.Renderer, mapEngine *d2mapengine.Map
|
||||
}
|
||||
|
||||
result.Camera = Camera{}
|
||||
startPosition := d2vector.NewPosition(0, 0)
|
||||
rx, ry := result.WorldToOrtho(startX, startY)
|
||||
startPosition := d2vector.NewPosition(rx, ry)
|
||||
result.Camera.position = &startPosition
|
||||
result.viewport.SetCamera(&result.Camera)
|
||||
|
||||
|
@ -51,13 +51,24 @@ func CreateGame(
|
||||
gameClient *d2client.GameClient,
|
||||
term d2interface.Terminal,
|
||||
) *Game {
|
||||
// find the local player and its initial location
|
||||
var startX, startY float64
|
||||
for _, player := range gameClient.Players {
|
||||
if player.ID != gameClient.PlayerID {
|
||||
continue
|
||||
}
|
||||
worldPosition := player.Position.World()
|
||||
startX, startY = worldPosition.X(), worldPosition.Y()
|
||||
break
|
||||
}
|
||||
|
||||
result := &Game{
|
||||
gameClient: gameClient,
|
||||
gameControls: nil,
|
||||
localPlayer: nil,
|
||||
lastRegionType: d2enum.RegionNone,
|
||||
ticksSinceLevelCheck: 0,
|
||||
mapRenderer: d2maprenderer.CreateMapRenderer(renderer, gameClient.MapEngine, term),
|
||||
mapRenderer: d2maprenderer.CreateMapRenderer(renderer, gameClient.MapEngine, term, startX, startY),
|
||||
escapeMenu: NewEscapeMenu(navigator, renderer, audioProvider),
|
||||
inputManager: inputManager,
|
||||
audioProvider: audioProvider,
|
||||
|
@ -186,7 +186,7 @@ func (met *MapEngineTest) OnLoad(loading d2screen.LoadingState) {
|
||||
|
||||
loading.Progress(fiftyPercent)
|
||||
|
||||
met.mapRenderer = d2maprenderer.CreateMapRenderer(met.renderer, met.mapEngine, met.terminal)
|
||||
met.mapRenderer = d2maprenderer.CreateMapRenderer(met.renderer, met.mapEngine, met.terminal, 0.0, 0.0)
|
||||
|
||||
loading.Progress(seventyPercent)
|
||||
met.loadRegionByIndex(met.currentRegion, met.levelPreset, met.fileIndex)
|
||||
|
Loading…
Reference in New Issue
Block a user