mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
minor general cleanup
This commit is contained in:
parent
dc514815c3
commit
0b39928334
6 changed files with 12 additions and 12 deletions
|
@ -6,8 +6,8 @@ namespace Demos.DesktopGL {
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
||||||
using (var game = new GameImpl())
|
using var game = new GameImpl();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,18 +128,19 @@ namespace MLEM.Extended.Tiled {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an enumerable of normals and penetration amounts for each <see cref="TileCollisionInfo"/> that intersects with the given <see cref="RectangleF"/> area.
|
/// Returns an enumerable of normals and penetration amounts for each <see cref="TileCollisionInfo"/> that intersects with the given <see cref="RectangleF"/> area.
|
||||||
/// The normals and penetration amounts are based on <see cref="MLEM.Extensions.NumberExtensions.Penetrate"/>.
|
/// The normals and penetration amounts are based on <see cref="MLEM.Extensions.NumberExtensions.Penetrate"/>.
|
||||||
/// Note that all x penetrations are returned before all y penetrations, which improves collision detection in sidescrolling games with gravity.
|
/// Note that all x penetrations are returned before all y penetrations, which improves collision detection in sidescrolling games with gravity. Note that this behavior can be inverted using <paramref name="prioritizeX"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="getArea">The area to penetrate</param>
|
/// <param name="getArea">The area to penetrate</param>
|
||||||
/// <param name="included">A function that determines if a certain info should be included or not</param>
|
/// <param name="included">A function that determines if a certain info should be included or not</param>
|
||||||
|
/// <param name="prioritizeX">Whether all x penetrations should be prioritized (returned first). If this is false, all y penetrations are prioritized instead.</param>
|
||||||
/// <returns>A set of normals and penetration amounts</returns>
|
/// <returns>A set of normals and penetration amounts</returns>
|
||||||
public IEnumerable<(Vector2, float)> GetPenetrations(Func<RectangleF> getArea, Func<TileCollisionInfo, bool> included = null) {
|
public IEnumerable<(Vector2, float)> GetPenetrations(Func<RectangleF> getArea, Func<TileCollisionInfo, bool> included = null, bool prioritizeX = true) {
|
||||||
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
|
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
|
||||||
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X != 0)
|
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X != 0 == prioritizeX)
|
||||||
yield return (normal, penetration);
|
yield return (normal, penetration);
|
||||||
}
|
}
|
||||||
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
|
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
|
||||||
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.Y != 0)
|
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X == 0 == prioritizeX)
|
||||||
yield return (normal, penetration);
|
yield return (normal, penetration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace TemplateNamespace {
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
||||||
using (var game = new GameImpl())
|
using var game = new GameImpl();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace MLEM.Misc {
|
||||||
/// This class contains a <see cref="DrawAutoTile"/> method that allows users to easily draw a tile with automatic connections.
|
/// This class contains a <see cref="DrawAutoTile"/> method that allows users to easily draw a tile with automatic connections.
|
||||||
/// For auto-tiling in this manner to work, auto-tiled textures have to be laid out in a format described in <see cref="DrawAutoTile"/>.
|
/// For auto-tiling in this manner to work, auto-tiled textures have to be laid out in a format described in <see cref="DrawAutoTile"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AutoTiling {
|
public static class AutoTiling {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method allows for a tiled texture to be drawn in an auto-tiling mode.
|
/// This method allows for a tiled texture to be drawn in an auto-tiling mode.
|
||||||
|
|
|
@ -21,7 +21,6 @@ using MLEM.Textures;
|
||||||
using MLEM.Ui;
|
using MLEM.Ui;
|
||||||
using MLEM.Ui.Elements;
|
using MLEM.Ui.Elements;
|
||||||
using MLEM.Ui.Style;
|
using MLEM.Ui.Style;
|
||||||
using MonoGame.Extended.BitmapFonts;
|
|
||||||
using MonoGame.Extended.Tiled;
|
using MonoGame.Extended.Tiled;
|
||||||
|
|
||||||
namespace Sandbox {
|
namespace Sandbox {
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace Sandbox {
|
||||||
|
|
||||||
private static void Main() {
|
private static void Main() {
|
||||||
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
||||||
using (var game = new GameImpl())
|
using var game = new GameImpl();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue