mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-05 19:14:14 -04: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:
parent
48f81c82cd
commit
458b17bcc6
@ -121,7 +121,18 @@ func (v *Engine) GetRegionAt(x, y int) *EngineRegion {
|
|||||||
|
|
||||||
func (v *Engine) Render(target *ebiten.Image) {
|
func (v *Engine) Render(target *ebiten.Image) {
|
||||||
for _, region := range v.regions {
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ func LoadRegion(seed int64, levelType d2enum.RegionIdType, levelPreset int, file
|
|||||||
seed: seed,
|
seed: seed,
|
||||||
}
|
}
|
||||||
result.Palette = d2datadict.Palettes[d2enum.PaletteType("act"+strconv.Itoa(int(result.LevelType.Act)))]
|
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
|
//bm := result.levelPreset.Dt1Mask
|
||||||
for _, levelTypeDt1 := range result.LevelType.Files {
|
for _, levelTypeDt1 := range result.LevelType.Files {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user