1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-27 20:46:32 -05:00

Increase draw distance up and down (#209)

* Scroll slowly in map test by holding shift
* Increase draw distance up and down
Avoid issues with long tiles popping in and out of view. (As long as
camera is reasonably within bounds)
This commit is contained in:
Ziemas 2019-11-19 00:23:33 +01:00 committed by Tim Sarbin
parent 9117616b0c
commit e70378d627
2 changed files with 23 additions and 7 deletions

View File

@ -218,16 +218,32 @@ func (v *MapEngineTest) Update(tickTime float64) {
shiftPressed := v.uiManager.KeyPressed(ebiten.KeyShift)
if v.uiManager.KeyPressed(ebiten.KeyDown) {
v.mapEngine.OffsetY -= tickTime * 800
if v.uiManager.KeyPressed(ebiten.KeyShift) {
v.mapEngine.OffsetY -= tickTime * 200
} else {
v.mapEngine.OffsetY -= tickTime * 800
}
}
if v.uiManager.KeyPressed(ebiten.KeyUp) {
v.mapEngine.OffsetY += tickTime * 800
if v.uiManager.KeyPressed(ebiten.KeyShift) {
v.mapEngine.OffsetY += tickTime * 200
} else {
v.mapEngine.OffsetY += tickTime * 800
}
}
if v.uiManager.KeyPressed(ebiten.KeyLeft) {
v.mapEngine.OffsetX += tickTime * 800
if v.uiManager.KeyPressed(ebiten.KeyShift) {
v.mapEngine.OffsetX += tickTime * 200
} else {
v.mapEngine.OffsetX += tickTime * 800
}
}
if v.uiManager.KeyPressed(ebiten.KeyRight) {
v.mapEngine.OffsetX -= tickTime * 800
if v.uiManager.KeyPressed(ebiten.KeyShift) {
v.mapEngine.OffsetX -= tickTime * 200
} else {
v.mapEngine.OffsetX -= tickTime * 800
}
}
if inpututil.IsKeyJustPressed(ebiten.KeyF7) {

View File

@ -180,7 +180,7 @@ func (v *Engine) GenTilesCache(region *EngineRegion) {
func (v *Engine) RenderRegion(region EngineRegion, target *ebiten.Image) {
for tileIdx := range region.Tiles {
sx, sy := d2helper.IsoToScreen(region.Tiles[tileIdx].tileX+region.Rect.Left, region.Tiles[tileIdx].tileY+region.Rect.Top, int(v.OffsetX), int(v.OffsetY))
if sx > -160 && sy > -160 && sx <= 880 && sy <= 1000 {
if sx > -160 && sy > -380 && sx <= 880 && sy <= 1240 {
v.RenderPass1(region.Region, region.Tiles[tileIdx].offX, region.Tiles[tileIdx].offY, region.Tiles[tileIdx].tileX, region.Tiles[tileIdx].tileY, target)
if v.ShowTiles > 0 {
v.DrawTileLines(region.Region, region.Tiles[tileIdx].offX, region.Tiles[tileIdx].offY, region.Tiles[tileIdx].tileX, region.Tiles[tileIdx].tileY, target)
@ -190,13 +190,13 @@ func (v *Engine) RenderRegion(region EngineRegion, target *ebiten.Image) {
}
for tileIdx := range region.Tiles {
sx, sy := d2helper.IsoToScreen(region.Tiles[tileIdx].tileX+region.Rect.Left, region.Tiles[tileIdx].tileY+region.Rect.Top, int(v.OffsetX), int(v.OffsetY))
if sx > -160 && sy > -160 && sx <= 880 && sy <= 1000 {
if sx > -160 && sy > -380 && sx <= 880 && sy <= 1240 {
v.RenderPass2(region.Region, region.Tiles[tileIdx].offX, region.Tiles[tileIdx].offY, region.Tiles[tileIdx].tileX, region.Tiles[tileIdx].tileY, target)
}
}
for tileIdx := range region.Tiles {
sx, sy := d2helper.IsoToScreen(region.Tiles[tileIdx].tileX+region.Rect.Left, region.Tiles[tileIdx].tileY+region.Rect.Top, int(v.OffsetX), int(v.OffsetY))
if sx > -160 && sy > -160 && sx <= 880 && sy <= 1000 {
if sx > -160 && sy > -380 && sx <= 880 && sy <= 1240 {
v.RenderPass3(region.Region, region.Tiles[tileIdx].offX, region.Tiles[tileIdx].offY, region.Tiles[tileIdx].tileX, region.Tiles[tileIdx].tileY, target)
}
}