1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-12-25 19:46:50 -05:00

Cleaned up the rendering some.

This commit is contained in:
Tim Sarbin 2018-11-24 20:34:21 -05:00
parent 1c0dede449
commit d3a718d8f6
2 changed files with 5 additions and 20 deletions

View File

@ -20,7 +20,6 @@ namespace OpenDiablo2.SDL2_
public Point Location { get; set; } = new Point();
public Size FrameSize { get; set; } = new Size();
private Point mapTileOffset = new Point();
private bool darken;
public bool Darken
@ -83,14 +82,9 @@ namespace OpenDiablo2.SDL2_
FrameSize = new Size(Pow2((int)source.Frames.Max(x => x.Width)), Pow2((int)source.Frames.Max(x => x.Height)));
}
private int[] idxtable = new int[] { 20, 21, 22, 23, 24, 15, 16, 17, 18, 19, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 };
public unsafe SDL2Sprite(IntPtr renderer, Palette palette, MPQDS1 mapData, int x, int y, eRenderCellType cellType)
{
this.renderer = renderer;
// TODO: Cell types
// Floor cell types
// Todo: multiple floor layers
var floorLayer = mapData.FloorLayers.First();
var floor = floorLayer.Props[x + (y * mapData.Width)];
@ -118,23 +112,14 @@ namespace OpenDiablo2.SDL2_
throw new ApplicationException("Could not locate tile!");
//FrameSize = new Size(tile.Width, Math.Abs(tile.Height));
FrameSize = new Size(tile.Width, Math.Abs(tile.Height));
TotalFrames = 1;
frame = 0;
IntPtr pixels;
int pitch;
var maxX = tile.Blocks.Max(z => z.PositionX + 32);
var maxY = tile.Blocks.Max(z => z.PositionY + 32);
var minX = tile.Blocks.Min(z => z.PositionX);
var minY = tile.Blocks.Min(z => z.PositionY);
FrameSize = new Size(Pow2(maxX - minX), Pow2(maxY - minY));
var yDiff = Math.Abs(minY);
var xDiff = Math.Abs(maxY);
mapTileOffset = new Point(minX, minY);
texture = SDL.SDL_CreateTexture(renderer, SDL.SDL_PIXELFORMAT_ARGB8888, (int)SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_STREAMING, FrameSize.Width, FrameSize.Height);
SDL.SDL_SetTextureBlendMode(texture, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
@ -151,8 +136,8 @@ namespace OpenDiablo2.SDL2_
foreach(var block in tile.Blocks)
{
var px = block.PositionX + xDiff;
var py = block.PositionY + yDiff;
var px = block.PositionX;
var py = block.PositionY;
//var px = 0;
//var py = 0;
@ -181,7 +166,7 @@ namespace OpenDiablo2.SDL2_
internal Point GetRenderPoint()
{
return source == null
? new Point(Location.X + mapTileOffset.X, (Location.Y - FrameSize.Height) + mapTileOffset.Y)
? Location
: new Point(Location.X + source.Frames[Frame].OffsetX, (Location.Y - FrameSize.Height) + source.Frames[Frame].OffsetY);
}

View File

@ -87,7 +87,7 @@ namespace OpenDiablo2.Scenes
for (int x = 0; x < gameState.MapData.Width; x++)
{
testSprite[idx] = renderWindow.GenerateMapCell(gameState.MapData, x, y, eRenderCellType.Floor, gameState.CurrentPalette);
testSprite[idx].Location = new Point(((x - y) * 80) - 900, ((x + y) * 40) - 900);
testSprite[idx].Location = new Point(((x - y) * 80) - 2900, ((x + y) * 40) - 1900);
idx++;
}
}