Browse Source

WIP: More changes to the Sprite class. Began implementing sprite drawing.

improved_timing
Ian Burgmyer 5 years ago
parent
commit
a743c8a8b6
  1. 9
      DotSDL/Graphics/SdlWindow.cs
  2. 20
      DotSDL/Graphics/Sprite.cs

9
DotSDL/Graphics/SdlWindow.cs

@ -3,6 +3,7 @@ using DotSDL.Input;
using DotSDL.Interop.Core;
using System;
using System.Collections.Generic;
using System.Linq;
namespace DotSDL.Graphics {
/// <summary>
@ -172,6 +173,7 @@ namespace DotSDL.Graphics {
Render.UpdateTexture(_texture, IntPtr.Zero, GetCanvasPointer(), TextureWidth * 4);
Render.RenderCopy(_renderer, _texture, IntPtr.Zero, IntPtr.Zero);
if(Sprites.Count > 0) DrawSprites();
Render.RenderPresent(_renderer);
}
@ -202,10 +204,13 @@ namespace DotSDL.Graphics {
/// <summary>
/// Plots the sprites stored in <see cref="Sprites"/> to the screen. Please note that this method is called by
/// DotSDL's drawing routines and does not need to be called manually. You usually do not need to override this
/// method.
/// DotSDL's drawing routines and does not need to be called manually. Additionally, this method will not be
/// called if there are no sprites defined. You usually do not need to override this method.
/// </summary>
public virtual void DrawSprites() {
foreach(var sprite in Sprites.Where(e => e.Shown).OrderBy(e => e.ZOrder)) {
SetScalingQuality(sprite.ScalingQuality);
}
}
/// <summary>

20
DotSDL/Graphics/Sprite.cs

@ -8,7 +8,13 @@ namespace DotSDL.Graphics {
/// <summary>
/// The position on the screen where the <see cref="Sprite"/> should be drawn.
/// </summary>
public Vector2 Position { get; set; }
public Point Position { get; set; }
/// <summary>
/// The angle that the sprite is drawn, in degrees. Incrementing this will rotate the
/// sprite clockwise.
/// </summary>
public float Rotation { get; set; }
/// <summary>
/// The scale of the <see cref="Sprite"/>. 1.0f is 100%.
@ -16,16 +22,22 @@ namespace DotSDL.Graphics {
public Vector2 Scale { get; set; }
/// <summary>
/// The order in which the sprite is drawn. Lower numbered <see cref="Sprite"/> instances are drawn first
/// and will appear on the bottom.
/// Determines the method that will be used to scale this sprite when it is plotted to the
/// screen.
/// </summary>
public int ZOrder { get; set; }
public ScalingQuality ScalingQuality { get; set; }
/// <summary>
/// <c>true</c> if the sprite should be drawn to the screen, otherwise <c>false</c>.
/// </summary>
public bool Shown { get; set; }
/// <summary>
/// The order in which the sprite is drawn. Lower numbered <see cref="Sprite"/> instances are drawn first
/// and will appear on the bottom.
/// </summary>
public int ZOrder { get; set; }
/// <summary>
/// Initializes a new <see cref="Sprite"/>.
/// </summary>

Loading…
Cancel
Save