mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 19:06:45 -05:00
All characters now render in their proper location on the map
This commit is contained in:
parent
b2177082dc
commit
9aa0f43cd8
@ -99,6 +99,9 @@ namespace OpenDiablo2.Core.Map_Engine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const int skewX = 400;
|
||||||
|
const int skewY = 300;
|
||||||
public void Render()
|
public void Render()
|
||||||
{
|
{
|
||||||
var xOffset = gameState.CameraOffset;
|
var xOffset = gameState.CameraOffset;
|
||||||
@ -106,9 +109,9 @@ namespace OpenDiablo2.Core.Map_Engine
|
|||||||
var cx = -(cameraLocation.X - Math.Truncate(cameraLocation.X));
|
var cx = -(cameraLocation.X - Math.Truncate(cameraLocation.X));
|
||||||
var cy = -(cameraLocation.Y - Math.Truncate(cameraLocation.Y));
|
var cy = -(cameraLocation.Y - Math.Truncate(cameraLocation.Y));
|
||||||
|
|
||||||
for (int ty = -7; ty <= 8; ty++)
|
for (int ty = -7; ty <= 9; ty++)
|
||||||
{
|
{
|
||||||
for (int tx = -7; tx <= 8; tx++)
|
for (int tx = -8; tx <= 8; tx++)
|
||||||
{
|
{
|
||||||
var ax = tx + Math.Truncate(cameraLocation.X);
|
var ax = tx + Math.Truncate(cameraLocation.X);
|
||||||
var ay = ty + Math.Truncate(cameraLocation.Y);
|
var ay = ty + Math.Truncate(cameraLocation.Y);
|
||||||
@ -121,24 +124,40 @@ namespace OpenDiablo2.Core.Map_Engine
|
|||||||
|
|
||||||
|
|
||||||
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.Floor))
|
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.Floor))
|
||||||
renderWindow.DrawMapCell(cellInfo, 320 + px + (int)ox + xOffset, 300 + py + (int)oy);
|
renderWindow.DrawMapCell(cellInfo, skewX + px + (int)ox + xOffset, skewY + py + (int)oy);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int ty = -7; ty <= 9; ty++)
|
||||||
|
{
|
||||||
|
for (int tx = -8; tx <= 8; tx++)
|
||||||
|
{
|
||||||
|
var ax = tx + Math.Truncate(cameraLocation.X);
|
||||||
|
var ay = ty + Math.Truncate(cameraLocation.Y);
|
||||||
|
|
||||||
|
var px = (tx - ty) * (cellSizeX / 2);
|
||||||
|
var py = (tx + ty) * (cellSizeY / 2);
|
||||||
|
|
||||||
|
var ox = (cx - cy) * (cellSizeX / 2);
|
||||||
|
var oy = (cx + cy) * (cellSizeY / 2);
|
||||||
|
|
||||||
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.WallLower))
|
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.WallLower))
|
||||||
renderWindow.DrawMapCell(cellInfo, 320 + px + (int)ox + xOffset, 300 + py + (int)oy + 80);
|
renderWindow.DrawMapCell(cellInfo, skewX + px + (int)ox + xOffset, skewY + py + (int)oy + 80);
|
||||||
|
|
||||||
|
foreach (var character in characterRenderers.Where(x => Math.Truncate(x.LocationDetails.PlayerX) == ax && Math.Truncate(x.LocationDetails.PlayerY) == ay))
|
||||||
|
{
|
||||||
|
var ptx = character.LocationDetails.PlayerX - Math.Truncate(cameraLocation.X);
|
||||||
|
var pty = character.LocationDetails.PlayerY - Math.Truncate(cameraLocation.Y);
|
||||||
|
|
||||||
|
var ppx = (ptx - pty) * (cellSizeX / 2);
|
||||||
|
var ppy = (ptx + pty) * (cellSizeY / 2);
|
||||||
|
|
||||||
|
character.Render(skewX + (int)ppx + (int)ox + xOffset, skewY + (int)ppy + (int)oy);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.WallUpper))
|
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.WallUpper))
|
||||||
renderWindow.DrawMapCell(cellInfo, 320 + px + (int)ox + xOffset, 300 + py + (int)oy);
|
renderWindow.DrawMapCell(cellInfo, skewX + px + (int)ox + xOffset, skewY + py + (int)oy);
|
||||||
|
|
||||||
// TODO: We need to render the characters infront of, or behind the wall properly...
|
|
||||||
if (ty == 0 && tx == 0)
|
|
||||||
{
|
|
||||||
foreach (var character in characterRenderers/*.Where(x => Math.Truncate(x.LocationDetails.PlayerX) == ax && Math.Truncate(x.LocationDetails.PlayerY) == ay)*/)
|
|
||||||
{
|
|
||||||
// TODO: Temporary hack
|
|
||||||
character.Render(400 + gameState.CameraOffset, 300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.Roof))
|
foreach (var cellInfo in gameState.GetMapCellInfo((int)ax, (int)ay, eRenderCellType.Roof))
|
||||||
renderWindow.DrawMapCell(cellInfo, 320 + px + (int)ox + xOffset, 300 + py + (int)oy);
|
renderWindow.DrawMapCell(cellInfo, 320 + px + (int)ox + xOffset, 300 + py + (int)oy);
|
||||||
|
Loading…
Reference in New Issue
Block a user