mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-28 22:26:30 -04:00
Cleaned up the rendering some.
This commit is contained in:
parent
1c0dede449
commit
d3a718d8f6
@ -20,7 +20,6 @@ namespace OpenDiablo2.SDL2_
|
|||||||
public Point Location { get; set; } = new Point();
|
public Point Location { get; set; } = new Point();
|
||||||
public Size FrameSize { get; set; } = new Size();
|
public Size FrameSize { get; set; } = new Size();
|
||||||
|
|
||||||
private Point mapTileOffset = new Point();
|
|
||||||
|
|
||||||
private bool darken;
|
private bool darken;
|
||||||
public 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)));
|
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)
|
public unsafe SDL2Sprite(IntPtr renderer, Palette palette, MPQDS1 mapData, int x, int y, eRenderCellType cellType)
|
||||||
{
|
{
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
// TODO: Cell types
|
|
||||||
|
|
||||||
// Floor cell types
|
|
||||||
// Todo: multiple floor layers
|
|
||||||
var floorLayer = mapData.FloorLayers.First();
|
var floorLayer = mapData.FloorLayers.First();
|
||||||
var floor = floorLayer.Props[x + (y * mapData.Width)];
|
var floor = floorLayer.Props[x + (y * mapData.Width)];
|
||||||
|
|
||||||
@ -118,23 +112,14 @@ namespace OpenDiablo2.SDL2_
|
|||||||
throw new ApplicationException("Could not locate tile!");
|
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;
|
TotalFrames = 1;
|
||||||
frame = 0;
|
frame = 0;
|
||||||
IntPtr pixels;
|
IntPtr pixels;
|
||||||
int pitch;
|
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);
|
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);
|
SDL.SDL_SetTextureBlendMode(texture, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
||||||
@ -151,8 +136,8 @@ namespace OpenDiablo2.SDL2_
|
|||||||
|
|
||||||
foreach(var block in tile.Blocks)
|
foreach(var block in tile.Blocks)
|
||||||
{
|
{
|
||||||
var px = block.PositionX + xDiff;
|
var px = block.PositionX;
|
||||||
var py = block.PositionY + yDiff;
|
var py = block.PositionY;
|
||||||
|
|
||||||
//var px = 0;
|
//var px = 0;
|
||||||
//var py = 0;
|
//var py = 0;
|
||||||
@ -181,7 +166,7 @@ namespace OpenDiablo2.SDL2_
|
|||||||
internal Point GetRenderPoint()
|
internal Point GetRenderPoint()
|
||||||
{
|
{
|
||||||
return source == null
|
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);
|
: new Point(Location.X + source.Frames[Frame].OffsetX, (Location.Y - FrameSize.Height) + source.Frames[Frame].OffsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
for (int x = 0; x < gameState.MapData.Width; x++)
|
for (int x = 0; x < gameState.MapData.Width; x++)
|
||||||
{
|
{
|
||||||
testSprite[idx] = renderWindow.GenerateMapCell(gameState.MapData, x, y, eRenderCellType.Floor, gameState.CurrentPalette);
|
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++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user