1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-16 04:25:23 +00:00

Only render visible regions (#230)

* Only render visible regions

This will need tweaking later to ensure there are no tiles popping in or
out of from regions coming in and out of view.

* Temp hack for act5 lava palette
This commit is contained in:
Ziemas 2019-11-23 14:48:33 +01:00 committed by Tim Sarbin
parent 48f81c82cd
commit 458b17bcc6
2 changed files with 16 additions and 1 deletions

View File

@ -121,7 +121,18 @@ func (v *Engine) GetRegionAt(x, y int) *EngineRegion {
func (v *Engine) Render(target *ebiten.Image) {
for _, region := range v.regions {
v.RenderRegion(region, target)
// X position of leftmost point of region
left := (region.Rect.Left - region.Rect.Bottom()) * 80
// Y position of top of region
top := (region.Rect.Left + region.Rect.Top) * 40
// X of right
right := (region.Rect.Right() - region.Rect.Top) * 80
// Y of bottom
bottom := (region.Rect.Right() + region.Rect.Bottom()) * 40
if -v.OffsetX+800 > float64(left) && -v.OffsetX < float64(right) && -v.OffsetY+600 > float64(top) && -v.OffsetY < float64(bottom) {
v.RenderRegion(region, target)
}
}
}

View File

@ -53,6 +53,10 @@ func LoadRegion(seed int64, levelType d2enum.RegionIdType, levelPreset int, file
seed: seed,
}
result.Palette = d2datadict.Palettes[d2enum.PaletteType("act"+strconv.Itoa(int(result.LevelType.Act)))]
// Temp hack
if levelType == d2enum.RegionAct5Lava {
result.Palette = d2datadict.Palettes[d2enum.PaletteType("act4")]
}
//bm := result.levelPreset.Dt1Mask
for _, levelTypeDt1 := range result.LevelType.Files {
/*