merge with develop and remove old demo

This commit is contained in:
Dylan Wilson
2019-08-27 21:21:40 +10:00
71 changed files with 914 additions and 1788 deletions
+1
View File
@@ -0,0 +1 @@
patreon: craftworkgames
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

+222 -221
View File
@@ -31,12 +31,7 @@
/processor:TexturePackerProcessor
/build:adventure-gui-atlas.json
#begin small-font.fnt
/importer:BitmapFontImporter
/processor:BitmapFontProcessor
/build:small-font.fnt
#begin small-font_0.png
#begin Animations/fireball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -46,7 +41,42 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:small-font_0.png
/build:Animations/fireball.png
#begin Animations/motw.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/motw.png
#begin Animations/zombie.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/zombie.png
#begin Animations/zombie-animations.aa
/importer:AstridAnimatorImporter
/processor:AstridAnimatorProcessor
/build:Animations/zombie-animations.aa
#begin Animations/zombie-atlas.json
/importer:JsonContentImporter
/processor:JsonContentProcessor
/processorParam:ContentType=TextureAtlas
/build:Animations/zombie-atlas.json
#begin Fonts/impact-32.fnt
/importer:BitmapFontImporter
@@ -82,19 +112,12 @@
/processorParam:TextureFormat=Color
/build:Fonts/montserrat-32_0.png
#begin Textures/logo-square-512.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-512.png
#begin small-font.fnt
/importer:BitmapFontImporter
/processor:BitmapFontProcessor
/build:small-font.fnt
#begin Textures/vignette.png
#begin small-font_0.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -104,175 +127,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/vignette.png
#begin Textures/hills.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills.png
#begin Textures/hills-sky.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-sky.png
#begin Textures/hills-clouds.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-clouds.png
#begin Textures/hills-4.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-4.png
#begin Textures/hills-3.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-3.png
#begin Textures/hills-2.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-2.png
#begin Textures/hills-1.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-1.png
#begin Textures/logo-square-128.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-128.png
#begin Textures/car-wheel.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/car-wheel.png
#begin Textures/car-hull.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/car-hull.png
#begin Textures/spike_ball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/spike_ball.png
#begin Textures/particle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/particle.png
#begin Textures/clipping-test.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/clipping-test.png
#begin Textures/bg_sharbi.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/bg_sharbi.png
/build:small-font_0.png
#begin Textures/axe.png
/importer:TextureImporter
@@ -286,7 +141,7 @@
/processorParam:TextureFormat=Color
/build:Textures/axe.png
#begin Animations/fireball.png
#begin Textures/bg_sharbi.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -296,9 +151,9 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/fireball.png
/build:Textures/bg_sharbi.png
#begin Animations/motw.png
#begin Textures/car-hull.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -308,19 +163,9 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/motw.png
/build:Textures/car-hull.png
#begin Animations/zombie-animations.aa
/importer:AstridAnimatorImporter
/processor:AstridAnimatorProcessor
/build:Animations/zombie-animations.aa
#begin Animations/zombie-atlas.json
/importer:TexturePackerJsonImporter
/processor:TexturePackerProcessor
/build:Animations/zombie-atlas.json
#begin Animations/zombie.png
#begin Textures/car-wheel.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -330,7 +175,175 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Animations/zombie.png
/build:Textures/car-wheel.png
#begin Textures/clipping-test.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/clipping-test.png
#begin Textures/colored_castle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/colored_castle.png
#begin Textures/hills.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills.png
#begin Textures/hills-1.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-1.png
#begin Textures/hills-2.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-2.png
#begin Textures/hills-3.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-3.png
#begin Textures/hills-4.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-4.png
#begin Textures/hills-clouds.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-clouds.png
#begin Textures/hills-sky.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/hills-sky.png
#begin Textures/logo-square-128.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-128.png
#begin Textures/logo-square-512.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/logo-square-512.png
#begin Textures/particle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/particle.png
#begin Textures/spike_ball.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/spike_ball.png
#begin Textures/vignette.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/vignette.png
#begin TiledMaps/abstractTiles_sheet.png
/importer:TextureImporter
@@ -444,6 +457,11 @@
/processor:TiledMapProcessor
/build:TiledMaps/level07.tmx
#begin TiledMaps/level08.tmx
/importer:TiledMapImporter
/processor:TiledMapProcessor
/build:TiledMaps/level08.tmx
#begin TiledMaps/non-uniform-tileset.png
/importer:TextureImporter
/processor:TextureProcessor
@@ -492,20 +510,3 @@
/processorParam:TextureFormat=Color
/build:TiledMaps/voxelTiles_sheet.png
#begin TiledMaps/level08.tmx
/importer:TiledMapImporter
/processor:TiledMapProcessor
/build:TiledMaps/level08.tmx
#begin Textures/colored_castle.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/colored_castle.png
@@ -1,5 +1,6 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
@@ -26,6 +27,8 @@ namespace Features.Demos
public AnimationsDemo(GameMain game) : base(game)
{
ContentTypeReaderManager.AddTypeCreator("TextureAtlas", () => new TextureAtlasJsonContentTypeReader());
ContentTypeReaderManager.AddTypeCreator("Default", () => new JsonContentTypeReader<TexturePackerFile>());
}
//protected override void Initialize()
@@ -288,7 +291,7 @@ namespace Features.Demos
//public void Draw(SpriteBatch spriteBatch)
//{
// //spriteBatch.Draw(_sprite);
// spriteBatch.Draw(_sprite, _transform);
//}
public void Walk(float direction)
+64 -25
View File
@@ -36,21 +36,21 @@ namespace Features.Demos
_blankTexture = new Texture2D(GraphicsDevice, 1, 1);
_blankTexture.SetData(new[] { Color.WhiteSmoke });
var demoBall1 = new DemoBall(new Sprite(_spikeyBallTexture))
var spikyBallLeft = new DemoBall(new Sprite(_spikeyBallTexture))
{
Position = new Vector2(200, 240),
Velocity = new Vector2(0, -120)
};
_actors.Add(demoBall1);
_actors.Add(spikyBallLeft);
var demoBall2 = new DemoBall(new Sprite(_spikeyBallTexture))
var spikeyBallRight = new DemoBall(new Sprite(_spikeyBallTexture))
{
Position = new Vector2(600, 240),
Velocity = new Vector2(0, 120)
};
_actors.Add(demoBall2);
_actors.Add(spikeyBallRight);
var controllableBall = new DemoBall(new Sprite(_spikeyBallTexture))
var controllableBall = new ControllableBall(new Sprite(_spikeyBallTexture))
{
Position = new Vector2(400, 240),
Velocity = new Vector2(0, 0)
@@ -58,26 +58,26 @@ namespace Features.Demos
_actors.Add(controllableBall);
_controllableBall = controllableBall;
var wall1 = new DemoWall(new Sprite(_blankTexture))
var topWall = new DemoWall(new Sprite(_blankTexture))
{
Bounds = new RectangleF(0, 0, 800, 20),
Position = new Vector2(0, 0)
};
_actors.Add(wall1);
_actors.Add(topWall);
var wall2 = new DemoWall(new Sprite(_blankTexture))
var bottomWall = new DemoWall(new Sprite(_blankTexture))
{
Position = new Vector2(0, 460),
Bounds = new RectangleF(0, 0, 800, 20)
};
_actors.Add(wall2);
_actors.Add(bottomWall);
var centerWall = new DemoWall(new Sprite(_blankTexture))
var spikeyBallCenter = new StationaryBall(new Sprite(_spikeyBallTexture))
{
Bounds = new RectangleF(0, 0, 50, 50),
Position = new Vector2(400, 200)
Position = new Vector2(400, 240),
Velocity = Vector2.Zero,
};
_actors.Add(centerWall);
_actors.Add(spikeyBallCenter);
foreach (var actor in _actors)
{
@@ -126,13 +126,6 @@ namespace Features.Demos
foreach (var actor in _actors)
{
actor.Draw(_spriteBatch);
if (actor.Bounds is RectangleF rect)
{
_spriteBatch.Draw(_blankTexture, rect.ToRectangle(), Color.WhiteSmoke);
} else if (actor.Bounds is CircleF circle)
{
_spriteBatch.Draw(_blankTexture, circle.Position, Color.WhiteSmoke);
}
}
_spriteBatch.End();
@@ -153,9 +146,10 @@ namespace Features.Demos
Bounds = sprite.GetBoundingRectangle(new Transform2());
}
public Vector2 Offset { get; set; }
/// <summary>
/// Gets or sets the actor's position and updates teh actor's bounds
/// position.
/// </summary>
public Vector2 Position
{
get { return _position; }
@@ -166,8 +160,20 @@ namespace Features.Demos
}
}
/// <summary>
/// Gets or sets the actor's collision bounds.
/// </summary>
public IShapeF Bounds { get; set; }
/// <summary>
/// Gets or sets how far the actor's collision bounds are offset from
/// the actor's position.
/// </summary>
public Vector2 Offset { get; set; }
/// <summary>
/// Gets or sets the actor's velocity.
/// </summary>
public Vector2 Velocity { get; set; }
public virtual void OnCollision(CollisionEventArgs collisionInfo)
@@ -201,14 +207,12 @@ namespace Features.Demos
{
public DemoBall(Sprite sprite) : base(sprite)
{
Offset = new Vector2(75, 75);
Bounds = new CircleF(Position + Offset, 60);
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
Bounds.Position = Position;
}
public override void OnCollision(CollisionEventArgs collisionInfo)
@@ -220,5 +224,40 @@ namespace Features.Demos
}
}
/// <summary>
/// Ball that doesn't move when collided with.
/// </summary>
class StationaryBall : DemoBall
{
public StationaryBall(Sprite sprite) : base(sprite)
{
}
public override void OnCollision(CollisionEventArgs collisionInfo)
{
}
}
/// <summary>
/// Player controlled ball.
/// </summary>
class ControllableBall : DemoBall
{
public ControllableBall(Sprite sprite) : base(sprite)
{
Bounds = new CircleF(Position + Offset, 60);
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
public override void OnCollision(CollisionEventArgs collisionInfo)
{
Position -= collisionInfo.PenetrationVector;
}
}
#endregion
}
+53
View File
@@ -0,0 +1,53 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Shapes;
namespace Features.Demos
{
public class ShapesDemo : DemoBase
{
private SpriteBatch _spriteBatch;
public ShapesDemo(GameMain game)
: base(game)
{
}
public override string Name => "Shapes";
private readonly Polygon _polygon = new Polygon(new[]
{
new Vector2(0, 0),
new Vector2(40, 0),
new Vector2(40, 40),
new Vector2(60, 40),
new Vector2(60, 60),
new Vector2(0, 60),
});
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Draw(GameTime gameTime)
{
_spriteBatch.Begin(samplerState: SamplerState.PointClamp, blendState: BlendState.AlphaBlend);
_spriteBatch.FillRectangle(10, 10, 50, 50, Color.DarkRed);
_spriteBatch.DrawRectangle(10, 10, 50, 50, Color.Red, 2);
_spriteBatch.DrawCircle(100, 100, 32, 32, Color.Green, 4);
_spriteBatch.DrawEllipse(new Vector2(200, 200), new Vector2(50, 25), 32, Color.Orange, 8);
_spriteBatch.DrawLine(300, 300, 400, 100, Color.White, 6);
_spriteBatch.DrawPoint(500, 300, Color.Brown, 64);
_spriteBatch.DrawPolygon(new Vector2(600, 200), _polygon, Color.Aqua);
_spriteBatch.End();
}
}
}
@@ -40,7 +40,7 @@ namespace Features.Demos
// the boxing viewport adapter uses letterboxing or pillarboxing to maintain aspect ratio
// it's a little more complicated and needs to listen to the window client size changing event
_boxingViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480, 88, 70);
_boxingViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);//, 88, 70);
// typically you'll only ever want to use one viewport adapter for a game, but in this sample we'll be
// switching between them.
@@ -68,13 +68,13 @@ namespace Features.Demos
Exit();
if (keyboardState.IsKeyDown(Keys.D))
_currentViewportAdapter = _defaultViewportAdapter;
SwitchAdapter(_defaultViewportAdapter);
if (keyboardState.IsKeyDown(Keys.S))
_currentViewportAdapter = _scalingViewportAdapter;
SwitchAdapter(_scalingViewportAdapter);
if (keyboardState.IsKeyDown(Keys.B))
_currentViewportAdapter = _boxingViewportAdapter;
SwitchAdapter(_boxingViewportAdapter);
// if we've changed the viewport adapter mid game we need to reset the viewport back to the window size
// this wouldn't normally be required if you're only ever using one viewport adapter
@@ -90,6 +90,12 @@ namespace Features.Demos
base.Update(gameTime);
}
private void SwitchAdapter(ViewportAdapter viewportAdapter)
{
_currentViewportAdapter?.Dispose();
_currentViewportAdapter = viewportAdapter;
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
+1
View File
@@ -45,6 +45,7 @@ namespace Features
//new GuiLayoutDemo(this),
//new GuiDemo(this),
//new ScreensDemo(this),
new ShapesDemo(this),
new ViewportAdaptersDemo(this),
new CollisionDemo(this),
new TiledMapsDemo(this),
-12
View File
@@ -1,12 +0,0 @@
using Microsoft.Xna.Framework;
using MonoGame.Extended;
namespace JamGame.Components
{
public class Body
{
public Vector2 Velocity { get; set; }
public Size2 Size { get; set; }
public bool IsHit { get; set; }
}
}
-6
View File
@@ -1,6 +0,0 @@
namespace JamGame.Components
{
public class Enemy
{
}
}
-12
View File
@@ -1,12 +0,0 @@
namespace JamGame.Components
{
public class Expiry
{
public Expiry(float timeRemaining)
{
TimeRemaining = timeRemaining;
}
public float TimeRemaining;
}
}
@@ -1,6 +0,0 @@
namespace JamGame.Components
{
public class Player
{
}
}
@@ -1,6 +0,0 @@
namespace JamGame.Components
{
public class Projectile
{
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

-45
View File
@@ -1,45 +0,0 @@
#----------------------------- Global Properties ----------------------------#
/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False
#-------------------------------- References --------------------------------#
/reference:..\..\..\MonoGame.Extended.Content.Pipeline\bin\netstandard2.0\MonoGame.Extended.Content.Pipeline.dll
#---------------------------------- Content ---------------------------------#
#begin 0x72_16x16DungeonTileset.v4.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:0x72_16x16DungeonTileset.v4.png
#begin Sensation.fnt
/importer:BitmapFontImporter
/processor:BitmapFontProcessor
/build:Sensation.fnt
#begin Sensation_0.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Sensation_0.png
-461
View File
@@ -1,461 +0,0 @@
<?xml version="1.0"?>
<font>
<info face="Sansation" size="18" bold="0" italic="0" charset="" unicode="1" stretchH="100" smooth="1" aa="1" padding="0,0,0,0" spacing="1,1" outline="0"/>
<common lineHeight="18" base="15" scaleW="128" scaleH="256" pages="1" packed="0" alphaChnl="0" redChnl="4" greenChnl="4" blueChnl="4"/>
<pages>
<page id="0" file="Sensation_0.png" />
</pages>
<chars count="190">
<char id="32" x="16" y="182" width="3" height="1" xoffset="-1" yoffset="17" xadvance="4" page="0" chnl="15" />
<char id="33" x="124" y="48" width="3" height="12" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="34" x="22" y="175" width="6" height="5" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="35" x="61" y="48" width="15" height="12" xoffset="0" yoffset="3" xadvance="15" page="0" chnl="15" />
<char id="36" x="90" y="126" width="8" height="12" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="37" x="95" y="61" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="38" x="108" y="74" width="11" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="39" x="75" y="171" width="3" height="4" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
<char id="40" x="107" y="32" width="4" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="41" x="66" y="32" width="5" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="42" x="8" y="175" width="6" height="6" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="43" x="0" y="175" width="7" height="6" xoffset="0" yoffset="8" xadvance="7" page="0" chnl="15" />
<char id="44" x="71" y="172" width="3" height="4" xoffset="0" yoffset="13" xadvance="3" page="0" chnl="15" />
<char id="45" x="0" y="182" width="5" height="2" xoffset="0" yoffset="10" xadvance="6" page="0" chnl="15" />
<char id="46" x="123" y="167" width="3" height="2" xoffset="0" yoffset="13" xadvance="3" page="0" chnl="15" />
<char id="47" x="18" y="142" width="8" height="12" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="48" x="96" y="74" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="49" x="112" y="139" width="4" height="11" xoffset="0" yoffset="4" xadvance="5" page="0" chnl="15" />
<char id="50" x="20" y="103" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="51" x="30" y="103" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="52" x="66" y="88" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="53" x="40" y="102" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="54" x="55" y="88" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="55" x="50" y="115" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="56" x="33" y="89" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="57" x="31" y="48" width="10" height="13" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="58" x="123" y="139" width="3" height="9" xoffset="0" yoffset="6" xadvance="3" page="0" chnl="15" />
<char id="59" x="107" y="139" width="4" height="11" xoffset="0" yoffset="6" xadvance="4" page="0" chnl="15" />
<char id="60" x="44" y="165" width="9" height="8" xoffset="0" yoffset="7" xadvance="9" page="0" chnl="15" />
<char id="61" x="57" y="173" width="7" height="4" xoffset="0" yoffset="9" xadvance="7" page="0" chnl="15" />
<char id="62" x="64" y="163" width="9" height="8" xoffset="0" yoffset="7" xadvance="9" page="0" chnl="15" />
<char id="63" x="50" y="102" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="64" x="0" y="0" width="16" height="15" xoffset="0" yoffset="3" xadvance="17" page="0" chnl="15" />
<char id="65" x="56" y="62" width="12" height="12" xoffset="0" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="66" x="60" y="101" width="9" height="12" xoffset="1" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="67" x="60" y="75" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="68" x="84" y="74" width="11" height="12" xoffset="1" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="69" x="70" y="101" width="9" height="12" xoffset="1" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="70" x="108" y="126" width="8" height="12" xoffset="1" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="71" x="12" y="77" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="72" x="24" y="76" width="11" height="12" xoffset="1" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="73" x="91" y="139" width="3" height="12" xoffset="1" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="74" x="120" y="87" width="6" height="12" xoffset="-1" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="75" x="44" y="89" width="10" height="12" xoffset="1" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="76" x="119" y="61" width="8" height="12" xoffset="1" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="77" x="14" y="63" width="13" height="12" xoffset="1" yoffset="3" xadvance="14" page="0" chnl="15" />
<char id="78" x="72" y="74" width="11" height="12" xoffset="1" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="79" x="28" y="63" width="13" height="12" xoffset="0" yoffset="3" xadvance="13" page="0" chnl="15" />
<char id="80" x="80" y="100" width="9" height="12" xoffset="1" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="81" x="59" y="0" width="13" height="15" xoffset="0" yoffset="3" xadvance="13" page="0" chnl="15" />
<char id="82" x="90" y="100" width="9" height="12" xoffset="1" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="83" x="22" y="90" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="84" x="11" y="90" width="10" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="85" x="0" y="77" width="11" height="12" xoffset="0" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="86" x="82" y="61" width="12" height="12" xoffset="0" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="87" x="93" y="48" width="15" height="12" xoffset="0" yoffset="3" xadvance="15" page="0" chnl="15" />
<char id="88" x="107" y="61" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="89" x="0" y="90" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="90" x="99" y="87" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="91" x="78" y="32" width="5" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="92" x="63" y="140" width="8" height="12" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="93" x="90" y="32" width="5" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="94" x="74" y="163" width="8" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="95" x="96" y="169" width="10" height="2" xoffset="-1" yoffset="15" xadvance="8" page="0" chnl="15" />
<char id="96" x="91" y="170" width="4" height="3" xoffset="1" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="97" x="9" y="165" width="8" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="98" x="100" y="100" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="99" x="18" y="165" width="8" height="9" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="100" x="110" y="100" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="101" x="63" y="153" width="9" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="102" x="120" y="74" width="7" height="12" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="103" x="0" y="116" width="9" height="12" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="104" x="10" y="116" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="105" x="99" y="139" width="3" height="12" xoffset="1" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="106" x="112" y="32" width="4" height="15" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="107" x="20" y="116" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="108" x="95" y="139" width="3" height="12" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="109" x="0" y="155" width="14" height="9" xoffset="0" yoffset="6" xadvance="14" page="0" chnl="15" />
<char id="110" x="73" y="153" width="9" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="111" x="53" y="154" width="9" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="112" x="30" y="116" width="9" height="12" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="113" x="40" y="115" width="9" height="12" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="114" x="27" y="165" width="6" height="9" xoffset="0" yoffset="6" xadvance="5" page="0" chnl="15" />
<char id="115" x="0" y="165" width="8" height="9" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="116" x="117" y="139" width="5" height="10" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
<char id="117" x="43" y="155" width="9" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="118" x="111" y="151" width="8" height="9" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="119" x="30" y="155" width="12" height="9" xoffset="0" yoffset="6" xadvance="12" page="0" chnl="15" />
<char id="120" x="102" y="152" width="8" height="9" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="121" x="27" y="142" width="8" height="12" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="122" x="93" y="152" width="8" height="9" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="123" x="96" y="32" width="5" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="124" x="122" y="32" width="3" height="15" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="125" x="72" y="32" width="5" height="15" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="126" x="107" y="169" width="7" height="2" xoffset="0" yoffset="10" xadvance="7" page="0" chnl="15" />
<char id="161" x="103" y="139" width="3" height="12" xoffset="0" yoffset="6" xadvance="4" page="0" chnl="15" />
<char id="162" x="99" y="126" width="8" height="12" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="163" x="42" y="48" width="9" height="13" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="164" x="34" y="165" width="9" height="8" xoffset="0" yoffset="7" xadvance="9" page="0" chnl="15" />
<char id="165" x="77" y="87" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="166" x="0" y="48" width="3" height="15" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="167" x="9" y="142" width="8" height="12" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="168" x="79" y="171" width="6" height="3" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="169" x="109" y="48" width="14" height="12" xoffset="0" yoffset="3" xadvance="14" page="0" chnl="15" />
<char id="170" x="42" y="174" width="5" height="5" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="171" x="104" y="162" width="8" height="6" xoffset="0" yoffset="8" xadvance="8" page="0" chnl="15" />
<char id="172" x="48" y="174" width="8" height="4" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="173" x="115" y="168" width="7" height="2" xoffset="0" yoffset="10" xadvance="7" page="0" chnl="15" />
<char id="174" x="54" y="164" width="9" height="8" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="175" x="6" y="182" width="5" height="2" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="176" x="29" y="175" width="6" height="5" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="177" x="120" y="150" width="7" height="9" xoffset="0" yoffset="6" xadvance="7" page="0" chnl="15" />
<char id="178" x="83" y="162" width="5" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="179" x="89" y="162" width="5" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="180" x="86" y="170" width="4" height="3" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
<char id="181" x="60" y="114" width="9" height="12" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="182" x="10" y="32" width="9" height="15" xoffset="-1" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="183" x="12" y="182" width="3" height="2" xoffset="0" yoffset="10" xadvance="4" page="0" chnl="15" />
<char id="184" x="65" y="172" width="5" height="4" xoffset="-1" yoffset="14" xadvance="4" page="0" chnl="15" />
<char id="185" x="122" y="160" width="3" height="6" xoffset="0" yoffset="4" xadvance="3" page="0" chnl="15" />
<char id="186" x="36" y="174" width="5" height="5" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
<char id="187" x="113" y="161" width="8" height="6" xoffset="0" yoffset="8" xadvance="8" page="0" chnl="15" />
<char id="188" x="48" y="75" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="189" x="36" y="76" width="11" height="12" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="190" x="69" y="61" width="12" height="12" xoffset="0" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="191" x="70" y="114" width="9" height="12" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="192" x="0" y="16" width="12" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="193" x="13" y="16" width="12" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="194" x="113" y="0" width="12" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="195" x="18" y="48" width="12" height="14" xoffset="0" yoffset="1" xadvance="12" page="0" chnl="15" />
<char id="196" x="100" y="0" width="12" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="197" x="87" y="0" width="12" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="198" x="77" y="48" width="15" height="12" xoffset="0" yoffset="3" xadvance="15" page="0" chnl="15" />
<char id="199" x="74" y="16" width="11" height="15" xoffset="0" yoffset="3" xadvance="11" page="0" chnl="15" />
<char id="200" x="20" y="32" width="9" height="15" xoffset="1" yoffset="0" xadvance="10" page="0" chnl="15" />
<char id="201" x="0" y="32" width="9" height="15" xoffset="1" yoffset="0" xadvance="10" page="0" chnl="15" />
<char id="202" x="30" y="32" width="9" height="15" xoffset="1" yoffset="0" xadvance="10" page="0" chnl="15" />
<char id="203" x="40" y="32" width="9" height="15" xoffset="1" yoffset="0" xadvance="10" page="0" chnl="15" />
<char id="204" x="117" y="32" width="4" height="15" xoffset="0" yoffset="0" xadvance="5" page="0" chnl="15" />
<char id="205" x="102" y="32" width="4" height="15" xoffset="1" yoffset="0" xadvance="5" page="0" chnl="15" />
<char id="206" x="84" y="32" width="5" height="15" xoffset="0" yoffset="0" xadvance="5" page="0" chnl="15" />
<char id="207" x="59" y="32" width="6" height="15" xoffset="-1" yoffset="0" xadvance="5" page="0" chnl="15" />
<char id="208" x="0" y="64" width="13" height="12" xoffset="-1" yoffset="3" xadvance="12" page="0" chnl="15" />
<char id="209" x="62" y="16" width="11" height="15" xoffset="1" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="210" x="73" y="0" width="13" height="15" xoffset="0" yoffset="0" xadvance="13" page="0" chnl="15" />
<char id="211" x="31" y="0" width="13" height="15" xoffset="0" yoffset="0" xadvance="13" page="0" chnl="15" />
<char id="212" x="45" y="0" width="13" height="15" xoffset="0" yoffset="0" xadvance="13" page="0" chnl="15" />
<char id="213" x="4" y="48" width="13" height="14" xoffset="0" yoffset="1" xadvance="13" page="0" chnl="15" />
<char id="214" x="17" y="0" width="13" height="15" xoffset="0" yoffset="0" xadvance="13" page="0" chnl="15" />
<char id="215" x="15" y="175" width="6" height="6" xoffset="0" yoffset="8" xadvance="7" page="0" chnl="15" />
<char id="216" x="42" y="62" width="13" height="12" xoffset="0" yoffset="3" xadvance="13" page="0" chnl="15" />
<char id="217" x="86" y="16" width="11" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="218" x="50" y="16" width="11" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="219" x="38" y="16" width="11" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="220" x="26" y="16" width="11" height="15" xoffset="0" yoffset="0" xadvance="12" page="0" chnl="15" />
<char id="221" x="98" y="16" width="10" height="15" xoffset="0" yoffset="0" xadvance="10" page="0" chnl="15" />
<char id="222" x="88" y="87" width="10" height="12" xoffset="0" yoffset="3" xadvance="10" page="0" chnl="15" />
<char id="223" x="80" y="113" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="224" x="0" y="142" width="8" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="225" x="72" y="140" width="8" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="226" x="117" y="126" width="8" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="227" x="54" y="141" width="8" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="228" x="45" y="141" width="8" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="229" x="52" y="48" width="8" height="13" xoffset="0" yoffset="2" xadvance="9" page="0" chnl="15" />
<char id="230" x="15" y="155" width="14" height="9" xoffset="0" yoffset="6" xadvance="14" page="0" chnl="15" />
<char id="231" x="36" y="142" width="8" height="12" xoffset="0" yoffset="6" xadvance="8" page="0" chnl="15" />
<char id="232" x="10" y="103" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="233" x="90" y="113" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="234" x="100" y="113" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="235" x="110" y="113" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="236" x="86" y="139" width="4" height="12" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="237" x="81" y="139" width="4" height="12" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="238" x="120" y="113" width="5" height="12" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="239" x="120" y="100" width="6" height="12" xoffset="-1" yoffset="3" xadvance="4" page="0" chnl="15" />
<char id="240" x="0" y="129" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="241" x="10" y="129" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="242" x="20" y="129" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="243" x="30" y="129" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="244" x="40" y="128" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="245" x="50" y="128" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="246" x="60" y="127" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="247" x="95" y="162" width="8" height="6" xoffset="0" yoffset="8" xadvance="8" page="0" chnl="15" />
<char id="248" x="83" y="152" width="9" height="9" xoffset="0" yoffset="6" xadvance="9" page="0" chnl="15" />
<char id="249" x="70" y="127" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="250" x="80" y="126" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="251" x="110" y="87" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="252" x="0" y="103" width="9" height="12" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="253" x="119" y="16" width="8" height="15" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
<char id="254" x="109" y="16" width="9" height="15" xoffset="0" yoffset="3" xadvance="9" page="0" chnl="15" />
<char id="255" x="50" y="32" width="8" height="15" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
</chars>
<kernings count="259">
<kerning first="52" second="55" amount="-1" />
<kerning first="54" second="55" amount="-1" />
<kerning first="54" second="57" amount="-1" />
<kerning first="55" second="52" amount="-1" />
<kerning first="55" second="54" amount="-1" />
<kerning first="221" second="193" amount="-1" />
<kerning first="65" second="84" amount="-1" />
<kerning first="65" second="86" amount="-1" />
<kerning first="65" second="89" amount="-1" />
<kerning first="221" second="194" amount="-1" />
<kerning first="65" second="221" amount="-1" />
<kerning first="221" second="195" amount="-1" />
<kerning first="221" second="192" amount="-1" />
<kerning first="221" second="248" amount="-1" />
<kerning first="221" second="230" amount="-1" />
<kerning first="70" second="65" amount="-1" />
<kerning first="70" second="196" amount="-1" />
<kerning first="70" second="197" amount="-1" />
<kerning first="70" second="198" amount="-1" />
<kerning first="70" second="192" amount="-1" />
<kerning first="70" second="195" amount="-1" />
<kerning first="70" second="194" amount="-1" />
<kerning first="70" second="193" amount="-1" />
<kerning first="221" second="198" amount="-1" />
<kerning first="221" second="252" amount="-1" />
<kerning first="221" second="251" amount="-1" />
<kerning first="75" second="67" amount="-1" />
<kerning first="75" second="71" amount="-1" />
<kerning first="75" second="79" amount="-1" />
<kerning first="75" second="81" amount="-1" />
<kerning first="75" second="199" amount="-1" />
<kerning first="75" second="214" amount="-1" />
<kerning first="75" second="216" amount="-1" />
<kerning first="75" second="213" amount="-1" />
<kerning first="221" second="249" amount="-1" />
<kerning first="75" second="211" amount="-1" />
<kerning first="75" second="212" amount="-1" />
<kerning first="75" second="210" amount="-1" />
<kerning first="221" second="250" amount="-1" />
<kerning first="221" second="245" amount="-1" />
<kerning first="221" second="246" amount="-1" />
<kerning first="221" second="244" amount="-1" />
<kerning first="221" second="242" amount="-1" />
<kerning first="221" second="243" amount="-1" />
<kerning first="221" second="241" amount="-1" />
<kerning first="221" second="235" amount="-1" />
<kerning first="221" second="234" amount="-1" />
<kerning first="221" second="232" amount="-1" />
<kerning first="221" second="233" amount="-1" />
<kerning first="76" second="67" amount="-1" />
<kerning first="76" second="71" amount="-1" />
<kerning first="76" second="79" amount="-1" />
<kerning first="76" second="81" amount="-1" />
<kerning first="76" second="84" amount="-2" />
<kerning first="76" second="86" amount="-2" />
<kerning first="76" second="89" amount="-2" />
<kerning first="76" second="199" amount="-1" />
<kerning first="76" second="214" amount="-1" />
<kerning first="76" second="216" amount="-1" />
<kerning first="76" second="213" amount="-1" />
<kerning first="221" second="231" amount="-1" />
<kerning first="221" second="229" amount="-1" />
<kerning first="76" second="211" amount="-1" />
<kerning first="76" second="212" amount="-1" />
<kerning first="76" second="210" amount="-1" />
<kerning first="76" second="221" amount="-2" />
<kerning first="221" second="227" amount="-1" />
<kerning first="221" second="228" amount="-1" />
<kerning first="221" second="226" amount="-1" />
<kerning first="221" second="224" amount="-1" />
<kerning first="221" second="225" amount="-1" />
<kerning first="221" second="197" amount="-1" />
<kerning first="221" second="196" amount="-1" />
<kerning first="221" second="122" amount="-1" />
<kerning first="221" second="120" amount="-1" />
<kerning first="221" second="117" amount="-1" />
<kerning first="221" second="115" amount="-1" />
<kerning first="221" second="114" amount="-1" />
<kerning first="221" second="113" amount="-1" />
<kerning first="221" second="112" amount="-1" />
<kerning first="221" second="111" amount="-1" />
<kerning first="80" second="65" amount="-1" />
<kerning first="80" second="74" amount="-1" />
<kerning first="80" second="196" amount="-1" />
<kerning first="80" second="197" amount="-1" />
<kerning first="80" second="198" amount="-1" />
<kerning first="80" second="192" amount="-1" />
<kerning first="80" second="195" amount="-1" />
<kerning first="80" second="194" amount="-1" />
<kerning first="80" second="193" amount="-1" />
<kerning first="221" second="110" amount="-1" />
<kerning first="221" second="109" amount="-1" />
<kerning first="221" second="103" amount="-1" />
<kerning first="221" second="101" amount="-1" />
<kerning first="83" second="83" amount="-1" />
<kerning first="221" second="100" amount="-1" />
<kerning first="84" second="65" amount="-1" />
<kerning first="84" second="74" amount="-1" />
<kerning first="84" second="97" amount="-1" />
<kerning first="84" second="99" amount="-1" />
<kerning first="84" second="100" amount="-1" />
<kerning first="84" second="101" amount="-1" />
<kerning first="84" second="103" amount="-1" />
<kerning first="84" second="109" amount="-1" />
<kerning first="84" second="110" amount="-1" />
<kerning first="84" second="111" amount="-1" />
<kerning first="84" second="112" amount="-1" />
<kerning first="84" second="113" amount="-1" />
<kerning first="84" second="114" amount="-1" />
<kerning first="84" second="115" amount="-1" />
<kerning first="84" second="116" amount="-1" />
<kerning first="84" second="117" amount="-1" />
<kerning first="84" second="118" amount="-1" />
<kerning first="84" second="119" amount="-1" />
<kerning first="84" second="120" amount="-1" />
<kerning first="84" second="121" amount="-1" />
<kerning first="84" second="122" amount="-1" />
<kerning first="84" second="196" amount="-1" />
<kerning first="84" second="197" amount="-1" />
<kerning first="84" second="225" amount="-1" />
<kerning first="84" second="224" amount="-1" />
<kerning first="84" second="226" amount="-1" />
<kerning first="84" second="228" amount="-1" />
<kerning first="84" second="227" amount="-1" />
<kerning first="84" second="229" amount="-1" />
<kerning first="84" second="231" amount="-1" />
<kerning first="84" second="233" amount="-1" />
<kerning first="84" second="232" amount="-1" />
<kerning first="84" second="234" amount="-1" />
<kerning first="84" second="235" amount="-1" />
<kerning first="84" second="243" amount="-1" />
<kerning first="84" second="242" amount="-1" />
<kerning first="84" second="244" amount="-1" />
<kerning first="84" second="246" amount="-1" />
<kerning first="84" second="245" amount="-1" />
<kerning first="84" second="250" amount="-1" />
<kerning first="84" second="249" amount="-1" />
<kerning first="84" second="251" amount="-1" />
<kerning first="84" second="252" amount="-1" />
<kerning first="84" second="198" amount="-1" />
<kerning first="84" second="230" amount="-1" />
<kerning first="84" second="248" amount="-1" />
<kerning first="84" second="192" amount="-1" />
<kerning first="84" second="195" amount="-1" />
<kerning first="221" second="99" amount="-1" />
<kerning first="84" second="194" amount="-1" />
<kerning first="84" second="193" amount="-1" />
<kerning first="221" second="97" amount="-1" />
<kerning first="221" second="65" amount="-1" />
<kerning first="193" second="221" amount="-1" />
<kerning first="193" second="89" amount="-1" />
<kerning first="193" second="86" amount="-1" />
<kerning first="193" second="84" amount="-1" />
<kerning first="194" second="221" amount="-1" />
<kerning first="194" second="89" amount="-1" />
<kerning first="194" second="86" amount="-1" />
<kerning first="194" second="84" amount="-1" />
<kerning first="195" second="221" amount="-1" />
<kerning first="195" second="89" amount="-1" />
<kerning first="195" second="86" amount="-1" />
<kerning first="195" second="84" amount="-1" />
<kerning first="192" second="221" amount="-1" />
<kerning first="192" second="89" amount="-1" />
<kerning first="192" second="86" amount="-1" />
<kerning first="192" second="84" amount="-1" />
<kerning first="197" second="221" amount="-1" />
<kerning first="197" second="89" amount="-1" />
<kerning first="197" second="86" amount="-1" />
<kerning first="197" second="84" amount="-1" />
<kerning first="196" second="221" amount="-1" />
<kerning first="196" second="89" amount="-1" />
<kerning first="196" second="86" amount="-1" />
<kerning first="196" second="84" amount="-1" />
<kerning first="89" second="193" amount="-1" />
<kerning first="89" second="194" amount="-1" />
<kerning first="89" second="195" amount="-1" />
<kerning first="89" second="192" amount="-1" />
<kerning first="89" second="248" amount="-1" />
<kerning first="89" second="230" amount="-1" />
<kerning first="89" second="198" amount="-1" />
<kerning first="89" second="252" amount="-1" />
<kerning first="89" second="251" amount="-1" />
<kerning first="89" second="249" amount="-1" />
<kerning first="89" second="250" amount="-1" />
<kerning first="89" second="245" amount="-1" />
<kerning first="89" second="246" amount="-1" />
<kerning first="89" second="244" amount="-1" />
<kerning first="89" second="242" amount="-1" />
<kerning first="89" second="243" amount="-1" />
<kerning first="89" second="241" amount="-1" />
<kerning first="89" second="235" amount="-1" />
<kerning first="89" second="234" amount="-1" />
<kerning first="89" second="232" amount="-1" />
<kerning first="89" second="233" amount="-1" />
<kerning first="89" second="231" amount="-1" />
<kerning first="89" second="229" amount="-1" />
<kerning first="86" second="65" amount="-1" />
<kerning first="86" second="97" amount="-1" />
<kerning first="86" second="99" amount="-1" />
<kerning first="86" second="100" amount="-1" />
<kerning first="86" second="101" amount="-1" />
<kerning first="86" second="103" amount="-1" />
<kerning first="86" second="109" amount="-1" />
<kerning first="86" second="110" amount="-1" />
<kerning first="86" second="111" amount="-1" />
<kerning first="86" second="112" amount="-1" />
<kerning first="86" second="113" amount="-1" />
<kerning first="86" second="114" amount="-1" />
<kerning first="86" second="115" amount="-1" />
<kerning first="86" second="122" amount="-1" />
<kerning first="86" second="196" amount="-1" />
<kerning first="86" second="197" amount="-1" />
<kerning first="86" second="225" amount="-1" />
<kerning first="86" second="224" amount="-1" />
<kerning first="86" second="226" amount="-1" />
<kerning first="86" second="228" amount="-1" />
<kerning first="86" second="227" amount="-1" />
<kerning first="86" second="229" amount="-1" />
<kerning first="86" second="231" amount="-1" />
<kerning first="86" second="233" amount="-1" />
<kerning first="86" second="232" amount="-1" />
<kerning first="86" second="234" amount="-1" />
<kerning first="86" second="235" amount="-1" />
<kerning first="86" second="241" amount="-1" />
<kerning first="86" second="243" amount="-1" />
<kerning first="86" second="242" amount="-1" />
<kerning first="86" second="244" amount="-1" />
<kerning first="86" second="246" amount="-1" />
<kerning first="86" second="245" amount="-1" />
<kerning first="86" second="198" amount="-1" />
<kerning first="86" second="230" amount="-1" />
<kerning first="86" second="248" amount="-1" />
<kerning first="86" second="192" amount="-1" />
<kerning first="86" second="195" amount="-1" />
<kerning first="89" second="227" amount="-1" />
<kerning first="86" second="194" amount="-1" />
<kerning first="86" second="193" amount="-1" />
<kerning first="89" second="228" amount="-1" />
<kerning first="89" second="226" amount="-1" />
<kerning first="89" second="224" amount="-1" />
<kerning first="89" second="225" amount="-1" />
<kerning first="89" second="197" amount="-1" />
<kerning first="89" second="196" amount="-1" />
<kerning first="89" second="122" amount="-1" />
<kerning first="89" second="120" amount="-1" />
<kerning first="89" second="117" amount="-1" />
<kerning first="89" second="115" amount="-1" />
<kerning first="89" second="114" amount="-1" />
<kerning first="89" second="113" amount="-1" />
<kerning first="89" second="112" amount="-1" />
<kerning first="89" second="111" amount="-1" />
<kerning first="89" second="110" amount="-1" />
<kerning first="89" second="109" amount="-1" />
<kerning first="89" second="103" amount="-1" />
<kerning first="89" second="101" amount="-1" />
<kerning first="89" second="100" amount="-1" />
<kerning first="89" second="99" amount="-1" />
<kerning first="89" second="97" amount="-1" />
<kerning first="89" second="65" amount="-1" />
</kernings>
</font>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

@@ -1,47 +0,0 @@
{ "frames": [
{
"filename": "fireball 0.aseprite",
"frame": { "x": 0, "y": 0, "w": 16, "h": 16 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 16 },
"sourceSize": { "w": 16, "h": 16 },
"duration": 100
},
{
"filename": "fireball 1.aseprite",
"frame": { "x": 16, "y": 0, "w": 16, "h": 16 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 16 },
"sourceSize": { "w": 16, "h": 16 },
"duration": 100
},
{
"filename": "fireball 2.aseprite",
"frame": { "x": 32, "y": 0, "w": 16, "h": 16 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 16 },
"sourceSize": { "w": 16, "h": 16 },
"duration": 100
},
{
"filename": "fireball 3.aseprite",
"frame": { "x": 48, "y": 0, "w": 16, "h": 16 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 16 },
"sourceSize": { "w": 16, "h": 16 },
"duration": 100
}
],
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.9-x64",
"image": "D:\\Github\\MonoGame.Extended\\Source\\Demos\\JamGame\\Content\\fireball.png",
"format": "I8",
"size": { "w": 64, "h": 16 },
"scale": "1"
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.1.5" orientation="orthogonal" renderorder="right-down" width="60" height="60" tilewidth="16" tileheight="16" infinite="0" nextobjectid="1">
<tileset firstgid="1" source="../../../../../../Downloads/DungeonTileset.tsx"/>
<layer name="background" width="60" height="60">
<data encoding="base64" compression="zlib">
eJzt00kKwkAQheG0unAbxQNEj+AxFDyAguNOwSFewOHgvoWBJnTHhJCF6X/xQaUaXiVFx0RR1JGuGEc9k7mjbxpiz6kie89fubEMZOipl7Jy9OOvkVXn9QrOMv3csz0nb1GQs5ZNwXmWm8hYJp76KCdHP2mIPaeKs1xK5E5r2MpO9nKomfUPrnKTVO4B7OEhT3nJu8Qe2sq3h9C09Z77hHbPQ/te/msAAAAAAAAAAAAAAAAAAAAAgM8HRmLDQA==
</data>
</layer>
<layer name="foreground" width="60" height="60">
<data encoding="base64" compression="zlib">
eJzt08EJAjEQBdBVK1ArUDuwKO1A+9h+BLEBy7ANc/AQcIUwiQbkPfgQQpj5lwwDrR1Sjr1L/NAp5fw67wve3wveXMNt2nh03k+d1n9wbDjrG/I/yLtL7wIfzFMWWWYTd9GUzIrsq+m4SllnWU7cRVMyK7KvpuM2ZZdlM3EXTcmsyL6ajkDcrXcBAAAAAAAAAAAAAP7aE8RUFWM=
</data>
</layer>
</map>
-82
View File
@@ -1,82 +0,0 @@
using System.Linq;
using JamGame.Components;
using Microsoft.Xna.Framework;
using MonoGame.Extended;
using MonoGame.Extended.Animations;
using MonoGame.Extended.Animations.SpriteSheets;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Sprites;
namespace JamGame
{
public class EntityFactory
{
private readonly Tileset _tileset;
public EntityFactory(Tileset tileset)
{
_tileset = tileset;
}
public World World { get; set; }
public void SpawnPlayer(float x, float y)
{
var entity = World.CreateEntity();
entity.Attach(new Sprite(_tileset.GetTile(232)));
entity.Attach(new Transform2(x, y));
entity.Attach(new Player());
entity.Attach(new Body { Size = new Size2(16, 16) });
}
public void SpawnSkeleton(float x, float y)
{
var entity = World.CreateEntity();
entity.Attach(new Sprite(_tileset.GetTile(145)));
entity.Attach(new Transform2(x, y));
entity.Attach(new Body { Size = new Size2(16, 16), Velocity = new Vector2(-8, 0) });
entity.Attach(new Enemy());
}
public void SpawnZombie(float x, float y)
{
var entity = World.CreateEntity();
entity.Attach(new Sprite(_tileset.GetTile(165)));
entity.Attach(new Transform2(x, y));
entity.Attach(new Body {Size = new Size2(16, 16), Velocity = new Vector2(-4, 0) });
entity.Attach(new Enemy());
}
public void SpawnPurpleThing(float x, float y)
{
var entity = World.CreateEntity();
entity.Attach(new Sprite(_tileset.GetTile(213)));
entity.Attach(new Transform2(x, y));
entity.Attach(new Body { Size = new Size2(16, 16), Velocity = new Vector2(-2, 0) });
entity.Attach(new Enemy());
}
public Entity SpawnFireball(float x, float y)
{
var entity = World.CreateEntity();
entity.Attach(new Sprite(_tileset.GetTile(240)));
entity.Attach(new Transform2(x, y) { Scale = Vector2.One * 0.75f });
entity.Attach(new Body { Size = new Size2(16, 16) });
entity.Attach(new Projectile());
return entity;
}
public void SpawnExplosion(Vector2 position, Vector2 velocity)
{
var frames = new[] {256, 257, 258, 259, 260, 261, 262, 263, 264};
var animationFactory = new SpriteSheetAnimationFactory(frames.Select(f => _tileset.GetTile(f)));
animationFactory.Add("explode", new SpriteSheetAnimationData(new []{0,1,2,3,4,5,6,7,8}, isLooping: false, frameDuration: 1f / 32f));
var entity = World.CreateEntity();
var animatedSprite = new AnimatedSprite(animationFactory);
entity.Attach(animatedSprite);
entity.Attach(new Transform2(position));
entity.Attach(new Body {Velocity = velocity});
animatedSprite.Play("explode", () => entity.Destroy());
}
}
}
-87
View File
@@ -1,87 +0,0 @@
using JamGame.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using MonoGame.Extended.BitmapFonts;
using MonoGame.Extended.Entities;
namespace JamGame
{
public class MainGame : Game
{
// ReSharper disable once NotAccessedField.Local
private GraphicsDeviceManager _graphicsDeviceManager;
private SpriteBatch _spriteBatch;
private World _world;
public MainGame()
{
_graphicsDeviceManager = new GraphicsDeviceManager(this)
{
PreferredBackBufferWidth = 1400,
PreferredBackBufferHeight = 900
};
Content.RootDirectory = "Content";
IsMouseVisible = true;
Window.AllowUserResizing = true;
}
public MouseState MouseState { get; private set; }
public KeyboardState KeyboardState { get; private set; }
protected override void LoadContent()
{
var font = Content.Load<BitmapFont>("Sensation");
var texture = Content.Load<Texture2D>("0x72_16x16DungeonTileset.v4");
var tileset = new Tileset(texture, 16, 16);
var entityFactory = new EntityFactory(tileset);
_spriteBatch = new SpriteBatch(GraphicsDevice);
_world = new WorldBuilder()
.AddSystem(new MapRenderingSystem(GraphicsDevice, tileset))
.AddSystem(new SpriteRenderingSystem(GraphicsDevice, texture))
.AddSystem(new HudSystem(this, GraphicsDevice, font, tileset))
.AddSystem(new PlayerControlSystem(this, entityFactory))
.AddSystem(new BodyMovementSystem())
.AddSystem(new CollisionSystem())
.AddSystem(new CollisionResponseSystem(entityFactory))
.Build();
entityFactory.World = _world;
entityFactory.SpawnPlayer(100, 100);
var random = new FastRandom();
for (var i = 0; i < 20; i++)
{
entityFactory.SpawnZombie(random.Next(150, 800), random.Next(0, 480));
//entityFactory.SpawnSkeleton(random.Next(150, 250), random.Next(110, 250));
//entityFactory.SpawnPurpleThing(random.Next(150, 250), random.Next(110, 250));
}
}
protected override void UnloadContent()
{
_spriteBatch.Dispose();
}
protected override void Update(GameTime gameTime)
{
MouseState = Mouse.GetState();
KeyboardState = Keyboard.GetState();
if (KeyboardState.IsKeyDown(Keys.Escape))
Exit();
_world.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
_world.Draw(gameTime);
base.Draw(gameTime);
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

-22
View File
@@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>
<ItemGroup>
<MonoGameContentReference Include="**\*.mgcb" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MonoGame.Extended.Content.Pipeline\MonoGame.Extended.Content.Pipeline.csproj" />
<ProjectReference Include="..\..\MonoGame.Extended.Entities\MonoGame.Extended.Entities.csproj" />
<ProjectReference Include="..\..\MonoGame.Extended.Input\MonoGame.Extended.Input.csproj" />
<ProjectReference Include="..\..\MonoGame.Extended.Tweening\MonoGame.Extended.Tweening.csproj" />
<ProjectReference Include="..\..\MonoGame.Extended\MonoGame.Extended.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.8" />
<PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.7.0.7" />
</ItemGroup>
</Project>
-14
View File
@@ -1,14 +0,0 @@
using System;
namespace JamGame
{
public static class Program
{
[STAThread]
public static void Main()
{
using (var game = new MainGame())
game.Run();
}
}
}
-5
View File
@@ -1,5 +0,0 @@
## Assets Used
- [16x16 Dungeon Tileset](https://0x72.itch.io/16x16-dungeon-tileset)
- [Kyrise's Free 16x16 RPG Icon Pack](https://kyrise.itch.io/kyrises-free-16x16-rpg-icon-pack)
@@ -1,38 +0,0 @@
using JamGame.Components;
using Microsoft.Xna.Framework;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
namespace JamGame.Systems
{
public class BodyMovementSystem : EntityUpdateSystem
{
private ComponentMapper<Transform2> _transformMapper;
private ComponentMapper<Body> _bodyMapper;
public BodyMovementSystem()
: base(Aspect.All(typeof(Transform2), typeof(Body)))
{
}
public override void Initialize(IComponentMapperService mapperService)
{
_transformMapper = mapperService.GetMapper<Transform2>();
_bodyMapper = mapperService.GetMapper<Body>();
}
public override void Update(GameTime gameTime)
{
var elapsedSeconds = gameTime.GetElapsedSeconds();
foreach (var entity in ActiveEntities)
{
var transform = _transformMapper.Get(entity);
var body = _bodyMapper.Get(entity);
transform.Position += body.Velocity * elapsedSeconds;
}
}
}
}
@@ -1,48 +0,0 @@
using JamGame.Components;
using Microsoft.Xna.Framework;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
namespace JamGame.Systems
{
public class CollisionResponseSystem : EntityProcessingSystem
{
private readonly EntityFactory _entityFactory;
private ComponentMapper<Body> _bodyMapper;
public CollisionResponseSystem(EntityFactory entityFactory)
: base(Aspect.All(typeof(Body), typeof(Transform2)))
{
_entityFactory = entityFactory;
}
public override void Initialize(IComponentMapperService mapperService)
{
_bodyMapper = mapperService.GetMapper<Body>();
}
public override void Process(GameTime gameTime, int entityId)
{
var body = _bodyMapper.Get(entityId);
if (body.IsHit)
{
var entity = GetEntity(entityId);
if (entity.Has<Projectile>())
{
_entityFactory.SpawnExplosion(entity.Get<Transform2>().Position, body.Velocity / 2f);
entity.Destroy();
}
if (entity.Has<Enemy>())
{
_entityFactory.SpawnExplosion(entity.Get<Transform2>().Position, body.Velocity / 2f);
entity.Destroy();
}
}
}
}
}
@@ -1,56 +0,0 @@
using JamGame.Components;
using Microsoft.Xna.Framework;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
namespace JamGame.Systems
{
public class CollisionSystem : EntityUpdateSystem
{
private ComponentMapper<Body> _bodyMapper;
private ComponentMapper<Transform2> _transformMapper;
public CollisionSystem()
: base(Aspect.All(typeof(Body), typeof(Transform2)))
{
}
public override void Initialize(IComponentMapperService mapperService)
{
_bodyMapper = mapperService.GetMapper<Body>();
_transformMapper = mapperService.GetMapper<Transform2>();
}
public override void Update(GameTime gameTime)
{
foreach (var entityA in ActiveEntities)
{
var bodyA = _bodyMapper.Get(entityA);
var transformA = _transformMapper.Get(entityA);
var rectangleA = GetBoundingRectangle(transformA, bodyA);
bodyA.IsHit = false;
foreach (var entityB in ActiveEntities)
{
var bodyB = _bodyMapper.Get(entityB);
var transformB = _transformMapper.Get(entityB);
var rectangleB = GetBoundingRectangle(transformB, bodyB);
if (entityA != entityB && rectangleA.Intersects(rectangleB))
{
bodyA.IsHit = true;
bodyB.IsHit = true;
}
}
}
}
private static RectangleF GetBoundingRectangle(Transform2 transform, Body body)
{
return new RectangleF(transform.Position.X - body.Size.Width / 2f, transform.Position.Y + body.Size.Height / 2f, body.Size.Width, body.Size.Height);
}
}
}
-42
View File
@@ -1,42 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.BitmapFonts;
using MonoGame.Extended.Entities.Systems;
using MonoGame.Extended.TextureAtlases;
namespace JamGame.Systems
{
public class HudSystem : DrawSystem
{
private readonly MainGame _game;
private readonly BitmapFont _font;
private readonly Tileset _tileset;
private readonly SpriteBatch _spriteBatch;
public HudSystem(MainGame game, GraphicsDevice graphicsDevice, BitmapFont font, Tileset tileset)
{
_game = game;
_font = font;
_tileset = tileset;
_spriteBatch = new SpriteBatch(graphicsDevice);
}
public override void Draw(GameTime gameTime)
{
var tx = _game.MouseState.X / _tileset.TileWidth / 2;
var ty = _game.MouseState.Y / _tileset.TileHeight / 2;
var region = _tileset.GetTileAt(tx, ty);
_spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(2));
_spriteBatch.DrawString(_font, $"{tx}, {ty}", Vector2.Zero, Color.AliceBlue);
_spriteBatch.DrawRectangle(tx * _tileset.TileWidth, ty * _tileset.TileHeight, _tileset.TileWidth, _tileset.TileHeight, Color.White);
if(region != null)
_spriteBatch.Draw(region, new Vector2(350, 0), Color.White);
_spriteBatch.End();
}
}
}
@@ -1,74 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Entities.Systems;
using MonoGame.Extended.TextureAtlases;
namespace JamGame.Systems
{
public class MapRenderingSystem : DrawSystem
{
private readonly GraphicsDevice _graphicsDevice;
private readonly Tileset _tileset;
private readonly SpriteBatch _spriteBatch;
private readonly FastRandom _random = new FastRandom();
private const int _mapWidth = 30;
private const int _mapHeight = 30;
private readonly int[,] _mapData = new int[_mapWidth, _mapHeight];
public MapRenderingSystem(GraphicsDevice graphicsDevice, Tileset tileset)
{
_graphicsDevice = graphicsDevice;
_tileset = tileset;
_spriteBatch = new SpriteBatch(graphicsDevice);
for (var x = 0; x < _mapWidth; x++)
{
for (var y = 0; y < _mapHeight; y++)
_mapData[x, y] = GetTileIndexAt(x, y);
}
}
private int GetTileIndexAt(int x, int y)
{
if (x < 3 || x > 19)
return -1;
if (y < 2 || y > 19)
return -1;
switch (y)
{
case 2: return x == 3 ? 0 : (x == 19 ? 1 : 2);
case 3: return x == 3 ? 16 : (x == 19 ? 18 : 17);
case 4: return _random.Next(32, 34);
default: return 50;
}
}
public override void Draw(GameTime gameTime)
{
_graphicsDevice.Clear(Color.DarkBlue * 0.2f);
_spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(2));
for (var x = 0; x < _mapWidth; x++)
{
for (var y = 0; y < _mapHeight; y++)
{
var tileIndex = _mapData[x, y];
if (tileIndex >= 0)
{
var tile = _tileset.GetTile(tileIndex);
var position = new Vector2(x * _tileset.TileWidth, y * _tileset.TileHeight);
_spriteBatch.Draw(tile, position, Color.White);
}
}
}
_spriteBatch.End();
}
}
}
@@ -1,82 +0,0 @@
using JamGame.Components;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
using MonoGame.Extended.Sprites;
namespace JamGame.Systems
{
public class PlayerControlSystem : EntityUpdateSystem
{
private readonly MainGame _mainGame;
private readonly EntityFactory _entityFactory;
private ComponentMapper<Transform2> _transformMapper;
private ComponentMapper<Sprite> _spriteMapper;
private const int _playerSpeed = 64;
private KeyboardState _previousKeyboardState;
private Entity _spawningFireball;
public PlayerControlSystem(MainGame mainGame, EntityFactory entityFactory)
: base(Aspect.All(typeof(Player), typeof(Transform2), typeof(Sprite)))
{
_mainGame = mainGame;
_entityFactory = entityFactory;
}
public override void Initialize(IComponentMapperService mapperService)
{
_transformMapper = mapperService.GetMapper<Transform2>();
_spriteMapper = mapperService.GetMapper<Sprite>();
}
public override void Update(GameTime gameTime)
{
var elapsedSeconds = gameTime.GetElapsedSeconds();
foreach (var entity in ActiveEntities)
{
var transform = _transformMapper.Get(entity);
var sprite = _spriteMapper.Get(entity);
if (_mainGame.KeyboardState.IsKeyDown(Keys.Left))
{
transform.Position += new Vector2(-_playerSpeed, 0) * elapsedSeconds;
sprite.Effect = SpriteEffects.FlipHorizontally;
}
if (_mainGame.KeyboardState.IsKeyDown(Keys.Right))
{
transform.Position += new Vector2(_playerSpeed, 0) * elapsedSeconds;
sprite.Effect = SpriteEffects.None;
}
if (_mainGame.KeyboardState.IsKeyDown(Keys.Up))
transform.Position += new Vector2(0, -_playerSpeed) * elapsedSeconds;
if (_mainGame.KeyboardState.IsKeyDown(Keys.Down))
transform.Position += new Vector2(0, _playerSpeed) * elapsedSeconds;
if (_previousKeyboardState.IsKeyUp(Keys.Space) && _mainGame.KeyboardState.IsKeyDown(Keys.Space))
_spawningFireball = _entityFactory.SpawnFireball(transform.Position.X + 16, transform.Position.Y);
// Kinda hacky but it works for now.
var spawningFireballBody = _spawningFireball?.Get<Body>();
if (spawningFireballBody != null && _previousKeyboardState.IsKeyDown(Keys.Space) && _mainGame.KeyboardState.IsKeyUp(Keys.Space))
{
spawningFireballBody.Velocity = new Vector2(200, 0);
_spawningFireball = null;
}
var spawningFireballTransform = _spawningFireball?.Get<Transform2>();
if(spawningFireballTransform != null)
spawningFireballTransform.Position = new Vector2(transform.Position.X + 16, transform.Position.Y);
}
_previousKeyboardState = _mainGame.KeyboardState;
}
}
}
@@ -1,50 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended;
using MonoGame.Extended.Animations;
using MonoGame.Extended.Entities;
using MonoGame.Extended.Entities.Systems;
using MonoGame.Extended.Sprites;
namespace JamGame.Systems
{
public class SpriteRenderingSystem : EntityDrawSystem
{
private readonly SpriteBatch _spriteBatch;
private ComponentMapper<Transform2> _transformMapper;
private ComponentMapper<Sprite> _spriteMapper;
private ComponentMapper<AnimatedSprite> _animatedSpriteMapper;
public SpriteRenderingSystem(GraphicsDevice graphicsDevice, Texture2D texture)
: base(Aspect.All(typeof(Transform2)).One(typeof(Sprite), typeof(AnimatedSprite)))
{
_spriteBatch = new SpriteBatch(graphicsDevice);
}
public override void Initialize(IComponentMapperService mapperService)
{
_transformMapper = mapperService.GetMapper<Transform2>();
_spriteMapper = mapperService.GetMapper<Sprite>();
_animatedSpriteMapper = mapperService.GetMapper<AnimatedSprite>();
}
public override void Draw(GameTime gameTime)
{
_spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(2));
foreach (var entity in ActiveEntities)
{
var transform = _transformMapper.Get(entity);
var animatedSprite = _animatedSpriteMapper.Get(entity);
var sprite = _spriteMapper.Get(entity);
animatedSprite?.Update(gameTime);
_spriteBatch.Draw(sprite ?? animatedSprite, transform);
}
_spriteBatch.End();
}
}
}
-41
View File
@@ -1,41 +0,0 @@
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.TextureAtlases;
namespace JamGame
{
public class Tileset
{
private readonly int _columns;
private readonly TextureAtlas _atlas;
public Tileset(Texture2D texture, int tileWidth, int tileHeight)
{
TileWidth = tileWidth;
TileHeight = tileHeight;
_atlas = TextureAtlas.Create("", texture, tileWidth, tileHeight);
_columns = texture.Width / tileWidth;
}
public int TileWidth { get; }
public int TileHeight { get; }
public TextureRegion2D GetTile(int index)
{
if (index < 0 || index >= _atlas.RegionCount)
return null;
return _atlas[index];
}
public TextureRegion2D GetTileAt(int x, int y)
{
if (x >= _columns)
return null;
var index = y * _columns + x;
return GetTile(index);
}
}
}
-42
View File
@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Pong"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
</windowsSettings>
</application>
</assembly>
@@ -9,7 +9,6 @@
<PackageTags>monogame animations spritesheet sprite</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -1,52 +1,64 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
using MonoGame.Extended.Content;
using MonoGame.Extended.TextureAtlases;
//using System.Collections.Generic;
//using Microsoft.Xna.Framework.Content;
//using MonoGame.Extended.Content;
//using MonoGame.Extended.TextureAtlases;
namespace MonoGame.Extended.Animations.SpriteSheets
{
//public class SpriteSheetAnimationFactoryReader : ContentTypeReader<SpriteSheetAnimationFactory>
//{
// protected override SpriteSheetAnimationFactory Read(ContentReader reader, SpriteSheetAnimationFactory existingInstance)
// {
// var textureAtlasAssetName = reader.GetRelativeAssetName(reader.ReadString());
// var textureAtlas = reader.ContentManager.Load<TextureAtlas>(textureAtlasAssetName);
// var frameCount = reader.ReadInt32();
// var regions = new List<TextureRegion2D>();
//namespace MonoGame.Extended.Animations.SpriteSheets
//{
//<<<<<<< HEAD
// //public class SpriteSheetAnimationFactoryReader : ContentTypeReader<SpriteSheetAnimationFactory>
// //{
// // protected override SpriteSheetAnimationFactory Read(ContentReader reader, SpriteSheetAnimationFactory existingInstance)
// // {
// // var textureAtlasAssetName = reader.GetRelativeAssetName(reader.ReadString());
// // var textureAtlas = reader.ContentManager.Load<TextureAtlas>(textureAtlasAssetName);
// // var frameCount = reader.ReadInt32();
// // var regions = new List<TextureRegion2D>();
//=======
// public class SpriteSheetAnimationFactoryReader : ContentTypeReader<SpriteSheetAnimationFactory>
// {
// protected override SpriteSheetAnimationFactory Read(ContentReader reader, SpriteSheetAnimationFactory existingInstance)
// {
// var relativeName = reader.ReadString();
// var textureAtlasAssetName = reader.GetRelativeAssetName(relativeName);
// var textureAtlas = reader.ContentManager.Load<TextureAtlas>(textureAtlasAssetName);
// var frameCount = reader.ReadInt32();
// var regions = new List<TextureRegion2D>();
//>>>>>>> develop
// for (var i = 0; i < frameCount; i++)
// {
// var frameName = reader.ReadString();
// var textureRegion = textureAtlas[frameName];
// regions.Add(textureRegion);
// }
// // for (var i = 0; i < frameCount; i++)
// // {
// // var frameName = reader.ReadString();
// // var textureRegion = textureAtlas[frameName];
// // regions.Add(textureRegion);
// // }
// var animationFactory = new SpriteSheetAnimationFactory(regions);
// var animationCount = reader.ReadInt32();
// // var animationFactory = new SpriteSheetAnimationFactory(regions);
// // var animationCount = reader.ReadInt32();
// for (var i = 0; i < animationCount; i++)
// {
// var name = reader.ReadString();
// var framesPerSecond = reader.ReadInt32();
// var isLooping = reader.ReadBoolean();
// var isReversed = reader.ReadBoolean();
// var isPingPong = reader.ReadBoolean();
// var frameDuration = 1.0f / framesPerSecond;
// var frameIndexCount = reader.ReadInt32();
// var frameIndicies = new int[frameIndexCount];
// // for (var i = 0; i < animationCount; i++)
// // {
// // var name = reader.ReadString();
// // var framesPerSecond = reader.ReadInt32();
// // var isLooping = reader.ReadBoolean();
// // var isReversed = reader.ReadBoolean();
// // var isPingPong = reader.ReadBoolean();
// // var frameDuration = 1.0f / framesPerSecond;
// // var frameIndexCount = reader.ReadInt32();
// // var frameIndicies = new int[frameIndexCount];
// for (var f = 0; f < frameIndexCount; f++)
// {
// var frameIndex = reader.ReadInt32();
// frameIndicies[f] = frameIndex;
// }
// // for (var f = 0; f < frameIndexCount; f++)
// // {
// // var frameIndex = reader.ReadInt32();
// // frameIndicies[f] = frameIndex;
// // }
// var animationData = new SpriteSheetAnimationData(frameIndicies, frameDuration, isLooping, isReversed,
// isPingPong);
// animationFactory.Add(name, animationData);
// }
// // var animationData = new SpriteSheetAnimationData(frameIndicies, frameDuration, isLooping, isReversed,
// // isPingPong);
// // animationFactory.Add(name, animationData);
// // }
// return animationFactory;
// }
//}
}
// // return animationFactory;
// // }
// //}
//}
@@ -9,7 +9,6 @@
<PackageTags>monogame collisions</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -36,20 +36,13 @@ namespace MonoGame.Extended.Collisions
/// <param name="gameTime"></param>
public override void Update(GameTime gameTime)
{
// Update bounding box locations.
foreach (var value in _targetDataDictionary.Values)
{
_collisionTree.Remove(value);
value.Bounds = value.Target.Bounds;
_collisionTree.Insert(value);
}
// Detect collisions
foreach (var value in _targetDataDictionary.Values)
{
_collisionTree.Remove(value);
var target = value.Target;
var collisions =_collisionTree.Query(target.Bounds)
.Where(data => data.Target != target);
var collisions =_collisionTree.Query(target.Bounds);
// Generate list of collision Infos
foreach (var other in collisions)
@@ -61,7 +54,9 @@ namespace MonoGame.Extended.Collisions
};
target.OnCollision(collisionInfo);
value.Bounds = value.Target.Bounds;
}
_collisionTree.Insert(value);
}
}
@@ -156,7 +151,10 @@ namespace MonoGame.Extended.Collisions
private static Vector2 PenetrationVector(CircleF circ1, CircleF circ2)
{
Debug.Assert(circ1.Intersects(circ2));
if (!circ1.Intersects(circ2))
{
return Vector2.Zero;
}
var displacement = Point2.Displacement(circ1.Center, circ2.Center);
@@ -0,0 +1,15 @@
using System.IO;
using Microsoft.Xna.Framework.Content.Pipeline;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentImporter(".json", DefaultProcessor = nameof(JsonContentProcessor), DisplayName = "JSON Importer - MonoGame.Extended")]
public class JsonContentImporter : ContentImporter<ContentImporterResult<string>>
{
public override ContentImporterResult<string> Import(string filename, ContentImporterContext context)
{
var json = File.ReadAllText(filename);
return new ContentImporterResult<string>(filename, json);
}
}
}
@@ -0,0 +1,31 @@
using System;
using System.ComponentModel;
using Microsoft.Xna.Framework.Content.Pipeline;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentProcessor(DisplayName = "JSON Processor - MonoGame.Extended")]
public class JsonContentProcessor : ContentProcessor<ContentImporterResult<string>, JsonContentProcessorResult>
{
[DefaultValue(typeof(Type), "System.Object")]
public string ContentType { get; set; }
public override JsonContentProcessorResult Process(ContentImporterResult<string> input, ContentProcessorContext context)
{
try
{
var output = new JsonContentProcessorResult
{
ContentType = ContentType,
Json = input.Data
};
return output;
}
catch (Exception ex)
{
context.Logger.LogMessage("Error {0}", ex);
throw;
}
}
}
}
@@ -0,0 +1,8 @@
namespace MonoGame.Extended.Content.Pipeline.Json
{
public class JsonContentProcessorResult
{
public string ContentType { get; set; }
public string Json { get; set; }
}
}
@@ -0,0 +1,27 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
namespace MonoGame.Extended.Content.Pipeline.Json
{
[ContentTypeWriter]
public class JsonContentTypeWriter : ContentTypeWriter<JsonContentProcessorResult>
{
private string _runtimeType;
protected override void Write(ContentWriter writer, JsonContentProcessorResult result)
{
_runtimeType = result.ContentType;
writer.Write(result.Json);
}
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return _runtimeType;// "MonoGame.Extended.Serialization.JsonContentTypeReader, MonoGame.Extended";
}
public override string GetRuntimeType(TargetPlatform targetPlatform)
{
return _runtimeType;// "MonoGame.Extended.Serialization.JsonContentTypeReader, MonoGame.Extended";
}
}
}
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsTool>True</IsTool>
</PropertyGroup>
<ItemGroup>
<Content Include="bin\netstandard2.0\*.dll" Pack="True" PackagePath="tools\" />
</ItemGroup>
<PropertyGroup>
<Authors>craftworkgames</Authors>
<Description>Content Pipeline importers and processors to make MonoGame more awesome.</Description>
<PackageTags>monogame content importer processor reader tiled texturepacker bmfont animations</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame ecs entity component system</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -26,6 +26,9 @@ namespace MonoGame.Extended.Entities
foreach (var drawSystem in _drawSystems)
drawSystem.Dispose();
_updateSystems.Clear();
_drawSystems.Clear();
base.Dispose();
}
@@ -9,7 +9,6 @@
<PackageTags>monogame graphics batcher effects</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame gui</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -7,6 +7,8 @@ namespace MonoGame.Extended.Input.InputListeners
{
public class KeyboardListener : InputListener
{
private Array _keysValues = Enum.GetValues(typeof(Keys));
private bool _isInitial;
private TimeSpan _lastPressTime;
@@ -50,7 +52,7 @@ namespace MonoGame.Extended.Input.InputListeners
{
if (!currentState.IsKeyDown(Keys.LeftAlt) && !currentState.IsKeyDown(Keys.RightAlt))
{
var pressedKeys = Enum.GetValues(typeof(Keys))
var pressedKeys = _keysValues
.Cast<Keys>()
.Where(key => currentState.IsKeyDown(key) && _previousState.IsKeyUp(key));
@@ -72,7 +74,7 @@ namespace MonoGame.Extended.Input.InputListeners
private void RaiseReleasedEvents(KeyboardState currentState)
{
var releasedKeys = Enum.GetValues(typeof(Keys))
var releasedKeys = _keysValues
.Cast<Keys>()
.Where(key => currentState.IsKeyUp(key) && _previousState.IsKeyDown(key));
@@ -99,4 +101,4 @@ namespace MonoGame.Extended.Input.InputListeners
}
}
}
}
}
@@ -9,7 +9,6 @@
<PackageTags>monogame input event based listeners</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame nuclex gui</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame particle system</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame scene graph node entity</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -9,7 +9,6 @@
<PackageTags>monogame tiled maps orthographic isometric</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -69,6 +69,10 @@ namespace MonoGame.Extended.Tiled
private void AddLayer(TiledMapLayer layer, bool root)
{
if (root) _layers.Add(layer);
if (_layersByName.ContainsKey(layer.Name))
throw new ArgumentException($"The TiledMap '{Name}' contains two or more layers named '{layer.Name}'. Please ensure all layers have unique names.");
_layersByName.Add(layer.Name, layer);
switch(layer)
@@ -9,7 +9,6 @@
<PackageTags>monogame animations tweening</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
+2 -13
View File
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2010
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Extended", "MonoGame.Extended\MonoGame.Extended.csproj", "{41724C52-3D50-45BB-81EB-3C8A247EAFD1}"
EndProject
@@ -92,8 +92,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpaceGame", "Demos\SpaceGam
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarWarrior", "Demos\StarWarrior\StarWarrior.csproj", "{B8D1B045-627E-4587-8CE0-6D5556A2B706}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JamGame", "Demos\JamGame\JamGame.csproj", "{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -342,14 +340,6 @@ Global
{B8D1B045-627E-4587-8CE0-6D5556A2B706}.Release|Any CPU.Build.0 = Release|Any CPU
{B8D1B045-627E-4587-8CE0-6D5556A2B706}.Release|x86.ActiveCfg = Release|Any CPU
{B8D1B045-627E-4587-8CE0-6D5556A2B706}.Release|x86.Build.0 = Release|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Debug|x86.Build.0 = Debug|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Release|Any CPU.Build.0 = Release|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Release|x86.ActiveCfg = Release|Any CPU
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -372,7 +362,6 @@ Global
{EC27F5D2-30A3-40BC-A81F-CACC58CE6C6C} = {932F8931-4A8D-4205-BFCF-98E794207786}
{6238F2A3-ABAE-4D9B-99BF-B195FBA49159} = {932F8931-4A8D-4205-BFCF-98E794207786}
{B8D1B045-627E-4587-8CE0-6D5556A2B706} = {932F8931-4A8D-4205-BFCF-98E794207786}
{DA792AA2-8905-46A0-A7B8-76A84FA41BA8} = {932F8931-4A8D-4205-BFCF-98E794207786}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8ED5A62D-25EC-4331-9F99-BDD1E10C02A0}
+3 -3
View File
@@ -85,11 +85,11 @@ namespace MonoGame.Extended.Collections
if(Count == 0)
return;
Count = 0;
// non-primitive types are cleared so the garbage collector can release them
if (!_isPrimitive)
Array.Clear(_items, 0, Count);
Count = 0;
}
public bool Contains(T element)
@@ -191,4 +191,4 @@ namespace MonoGame.Extended.Collections
}
}
}
}
}
@@ -15,10 +15,15 @@ namespace MonoGame.Extended.Content
return (GraphicsDevice)_contentReaderGraphicsDeviceFieldInfo.GetValue(contentReader);
}
public static string RemoveExtension(string path)
{
return Path.ChangeExtension(path, null).TrimEnd('.');
}
public static string GetRelativeAssetName(this ContentReader contentReader, string relativeName)
{
var assetDirectory = Path.GetDirectoryName(contentReader.AssetName);
var assetName = Path.Combine(assetDirectory, relativeName).Replace('\\', '/');
var assetName = RemoveExtension(Path.Combine(assetDirectory, relativeName).Replace('\\', '/'));
return ShortenRelativePath(assetName);
}
+107 -70
View File
@@ -18,7 +18,12 @@ namespace MonoGame.Extended
if (_whitePixelTexture == null)
{
_whitePixelTexture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
_whitePixelTexture.SetData(new[] {Color.White});
_whitePixelTexture.SetData(new[] { Color.White });
spriteBatch.Disposing += (sender, args) =>
{
_whitePixelTexture?.Dispose();
_whitePixelTexture = null;
};
}
return _whitePixelTexture;
@@ -33,10 +38,10 @@ namespace MonoGame.Extended
/// <param name="polygon">The polygon to draw</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the lines</param>
public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 position, Polygon polygon, Color color,
float thickness = 1f)
/// /// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 position, Polygon polygon, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawPolygon(spriteBatch, position, polygon.Vertices, color, thickness);
DrawPolygon(spriteBatch, position, polygon.Vertices, color, thickness, layerDepth);
}
/// <summary>
@@ -48,61 +53,61 @@ namespace MonoGame.Extended
/// <param name="points">The points to connect with lines</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the lines</param>
public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 offset, IReadOnlyList<Vector2> points, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawPolygon(this SpriteBatch spriteBatch, Vector2 offset, IReadOnlyList<Vector2> points, Color color, float thickness = 1f, int layerDepth = 0)
{
if (points.Count == 0)
return;
if (points.Count == 1)
{
DrawPoint(spriteBatch, points[0], color, (int) thickness);
DrawPoint(spriteBatch, points[0], color, (int)thickness);
return;
}
var texture = GetTexture(spriteBatch);
for (var i = 0; i < points.Count - 1; i++)
DrawPolygonEdge(spriteBatch, texture, points[i] + offset, points[i + 1] + offset, color, thickness);
DrawPolygonEdge(spriteBatch, texture, points[i] + offset, points[i + 1] + offset, color, thickness, layerDepth);
DrawPolygonEdge(spriteBatch, texture, points[points.Count - 1] + offset, points[0] + offset, color,
thickness);
DrawPolygonEdge(spriteBatch, texture, points[points.Count - 1] + offset, points[0] + offset, color, thickness, layerDepth);
}
private static void DrawPolygonEdge(SpriteBatch spriteBatch, Texture2D texture, Vector2 point1, Vector2 point2,
Color color, float thickness)
private static void DrawPolygonEdge(SpriteBatch spriteBatch, Texture2D texture, Vector2 point1, Vector2 point2, Color color, float thickness, int layerDepth)
{
var length = Vector2.Distance(point1, point2);
var angle = (float) Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
var angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
var scale = new Vector2(length, thickness);
spriteBatch.Draw(texture, point1, null, color, angle, Vector2.Zero, scale, SpriteEffects.None, 0);
spriteBatch.Draw(texture, point1, null, color, angle, Vector2.Zero, scale, SpriteEffects.None, layerDepth);
}
/// <summary>
/// Draws a filled rectangle
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rectangle">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle(this SpriteBatch spriteBatch, RectangleF rectangle, Color color)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void FillRectangle(this SpriteBatch spriteBatch, RectangleF rectangle, Color color, int layerDepth = 0)
{
FillRectangle(spriteBatch, rectangle.Position, rectangle.Size, color);
FillRectangle(spriteBatch, rectangle.Position, rectangle.Size, color, layerDepth);
}
/// <summary>
/// Draws a filled rectangle
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="location">Where to draw</param>
/// <param name="size">The size of the rectangle</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle(this SpriteBatch spriteBatch, Vector2 location, Size2 size, Color color)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void FillRectangle(this SpriteBatch spriteBatch, Vector2 location, Size2 size, Color color, int layerDepth = 0)
{
spriteBatch.Draw(GetTexture(spriteBatch), location, null, color, 0, Vector2.Zero, size, SpriteEffects.None, 0);
spriteBatch.Draw(GetTexture(spriteBatch), location, null, color, 0, Vector2.Zero, size, SpriteEffects.None, layerDepth);
}
/// <summary>
/// Draws a filled rectangle
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The X coord of the left side</param>
@@ -110,19 +115,21 @@ namespace MonoGame.Extended
/// <param name="width">Width</param>
/// <param name="height">Height</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle(this SpriteBatch spriteBatch, float x, float y, float width, float height, Color color)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void FillRectangle(this SpriteBatch spriteBatch, float x, float y, float width, float height, Color color, int layerDepth = 0)
{
FillRectangle(spriteBatch, new Vector2(x, y), new Size2(width, height), color);
FillRectangle(spriteBatch, new Vector2(x, y), new Size2(width, height), color, layerDepth);
}
/// <summary>
/// Draws a rectangle with the thickness provided
/// Draws a rectangle with the thickness provided
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rectangle">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="thickness">The thickness of the lines</param>
public static void DrawRectangle(this SpriteBatch spriteBatch, RectangleF rectangle, Color color, float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawRectangle(this SpriteBatch spriteBatch, RectangleF rectangle, Color color, float thickness = 1f, int layerDepth = 0)
{
var texture = GetTexture(spriteBatch);
var topLeft = new Vector2(rectangle.X, rectangle.Y);
@@ -131,10 +138,10 @@ namespace MonoGame.Extended
var horizontalScale = new Vector2(rectangle.Width, thickness);
var verticalScale = new Vector2(thickness, rectangle.Height);
spriteBatch.Draw(texture, topLeft, null, color, 0f, Vector2.Zero, horizontalScale, SpriteEffects.None, 0);
spriteBatch.Draw(texture, topLeft, null, color, 0f, Vector2.Zero, verticalScale, SpriteEffects.None, 0);
spriteBatch.Draw(texture, topRight, null, color, 0f, Vector2.Zero, verticalScale, SpriteEffects.None, 0);
spriteBatch.Draw(texture, bottomLeft, null, color, 0f, Vector2.Zero, horizontalScale, SpriteEffects.None, 0);
spriteBatch.Draw(texture, topLeft, null, color, 0f, Vector2.Zero, horizontalScale, SpriteEffects.None, layerDepth);
spriteBatch.Draw(texture, topLeft, null, color, 0f, Vector2.Zero, verticalScale, SpriteEffects.None, layerDepth);
spriteBatch.Draw(texture, topRight, null, color, 0f, Vector2.Zero, verticalScale, SpriteEffects.None, layerDepth);
spriteBatch.Draw(texture, bottomLeft, null, color, 0f, Vector2.Zero, horizontalScale, SpriteEffects.None, layerDepth);
}
/// <summary>
@@ -145,23 +152,23 @@ namespace MonoGame.Extended
/// <param name="size">The size of the rectangle</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawRectangle(this SpriteBatch spriteBatch, Vector2 location, Size2 size, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawRectangle(this SpriteBatch spriteBatch, Vector2 location, Size2 size, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawRectangle(spriteBatch, new RectangleF(location.X, location.Y, size.Width, size.Height), color, thickness);
DrawRectangle(spriteBatch, new RectangleF(location.X, location.Y, size.Width, size.Height), color, thickness, layerDepth);
}
/// <summary>
/// Draws a rectangle outline.
/// </summary>
public static void DrawRectangle(this SpriteBatch spriteBatch, float x, float y, float width, float height, Color color, float thickness = 1f)
public static void DrawRectangle(this SpriteBatch spriteBatch, float x, float y, float width, float height, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawRectangle(spriteBatch, new RectangleF(x, y, width, height), color, thickness);
DrawRectangle(spriteBatch, new RectangleF(x, y, width, height), color, thickness, layerDepth);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x1">The X coord of the first point</param>
@@ -170,34 +177,34 @@ namespace MonoGame.Extended
/// <param name="y2">The Y coord of the second point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine(this SpriteBatch spriteBatch, float x1, float y1, float x2, float y2, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawLine(this SpriteBatch spriteBatch, float x1, float y1, float x2, float y2, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawLine(spriteBatch, new Vector2(x1, y1), new Vector2(x2, y2), color, thickness);
DrawLine(spriteBatch, new Vector2(x1, y1), new Vector2(x2, y2), color, thickness, layerDepth);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point1">The first point</param>
/// <param name="point2">The second point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point1, Vector2 point2, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point1, Vector2 point2, Color color, float thickness = 1f, int layerDepth = 0)
{
// calculate the distance between the two vectors
var distance = Vector2.Distance(point1, point2);
// calculate the angle between the two vectors
var angle = (float) Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
var angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
DrawLine(spriteBatch, point1, distance, angle, color, thickness);
DrawLine(spriteBatch, point1, distance, angle, color, thickness, layerDepth);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point">The starting point</param>
@@ -205,48 +212,48 @@ namespace MonoGame.Extended
/// <param name="angle">The angle of this line from the starting point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point, float length, float angle, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point, float length, float angle, Color color, float thickness = 1f, int layerDepth = 0)
{
var origin = new Vector2(0f, 0.5f);
var scale = new Vector2(length, thickness);
spriteBatch.Draw(GetTexture(spriteBatch), point, null, color, angle, origin, scale, SpriteEffects.None, 0);
spriteBatch.Draw(GetTexture(spriteBatch), point, null, color, angle, origin, scale, SpriteEffects.None, layerDepth);
}
/// <summary>
/// Draws a point at the specified x, y position. The center of the point will be at the position.
/// Draws a point at the specified x, y position. The center of the point will be at the position.
/// </summary>
public static void DrawPoint(this SpriteBatch spriteBatch, float x, float y, Color color, float size = 1f)
public static void DrawPoint(this SpriteBatch spriteBatch, float x, float y, Color color, float size = 1f, int layerDepth = 0)
{
DrawPoint(spriteBatch, new Vector2(x, y), color, size);
DrawPoint(spriteBatch, new Vector2(x, y), color, size, layerDepth);
}
/// <summary>
/// Draws a point at the specified position. The center of the point will be at the position.
/// Draws a point at the specified position. The center of the point will be at the position.
/// </summary>
public static void DrawPoint(this SpriteBatch spriteBatch, Vector2 position, Color color, float size = 1f)
public static void DrawPoint(this SpriteBatch spriteBatch, Vector2 position, Color color, float size = 1f, int layerDepth = 0)
{
var scale = Vector2.One*size;
var offset = new Vector2(0.5f) - new Vector2(size*0.5f);
spriteBatch.Draw(GetTexture(spriteBatch), position + offset, null, color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0);
var scale = Vector2.One * size;
var offset = new Vector2(0.5f) - new Vector2(size * 0.5f);
spriteBatch.Draw(GetTexture(spriteBatch), position + offset, null, color, 0f, Vector2.Zero, scale, SpriteEffects.None, layerDepth);
}
/// <summary>
/// Draw a circle from a <see cref="CircleF" /> shape
/// Draw a circle from a <see cref="CircleF" /> shape
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="circle">The circle shape to draw</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
/// <param name="thickness">The thickness of the lines used</param>
public static void DrawCircle(this SpriteBatch spriteBatch, CircleF circle, int sides, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawCircle(this SpriteBatch spriteBatch, CircleF circle, int sides, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawCircle(spriteBatch, circle.Center, circle.Radius, sides, color, thickness);
DrawCircle(spriteBatch, circle.Center, circle.Radius, sides, color, thickness, layerDepth);
}
/// <summary>
/// Draw a circle
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">The center of the circle</param>
@@ -254,14 +261,14 @@ namespace MonoGame.Extended
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
/// <param name="thickness">The thickness of the lines used</param>
public static void DrawCircle(this SpriteBatch spriteBatch, Vector2 center, float radius, int sides, Color color,
float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawCircle(this SpriteBatch spriteBatch, Vector2 center, float radius, int sides, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawPolygon(spriteBatch, center, CreateCircle(radius, sides), color, thickness);
DrawPolygon(spriteBatch, center, CreateCircle(radius, sides), color, thickness, layerDepth);
}
/// <summary>
/// Draw a circle
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The center X of the circle</param>
@@ -270,26 +277,56 @@ namespace MonoGame.Extended
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawCircle(this SpriteBatch spriteBatch, float x, float y, float radius, int sides,
Color color, float thickness = 1f)
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawCircle(this SpriteBatch spriteBatch, float x, float y, float radius, int sides, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawPolygon(spriteBatch, new Vector2(x, y), CreateCircle(radius, sides), color, thickness);
DrawPolygon(spriteBatch, new Vector2(x, y), CreateCircle(radius, sides), color, thickness, layerDepth);
}
/// <summary>
/// Draw an ellipse.
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">Center of the ellipse</param>
/// <param name="radius">Radius of the ellipse</param>
/// <param name="sides">The number of sides to generate.</param>
/// <param name="color">The color of the ellipse.</param>
/// <param name="thickness">The thickness of the line around the ellipse.</param>
/// <param name="layerDepth">The depth of the layer of this shape</param>
public static void DrawEllipse(this SpriteBatch spriteBatch, Vector2 center, Vector2 radius, int sides, Color color, float thickness = 1f, int layerDepth = 0)
{
DrawPolygon(spriteBatch, center, CreateEllipse(radius.X, radius.Y, sides), color, thickness, layerDepth);
}
private static Vector2[] CreateCircle(double radius, int sides)
{
const double max = 2.0*Math.PI;
const double max = 2.0 * Math.PI;
var points = new Vector2[sides];
var step = max/sides;
var step = max / sides;
var theta = 0.0;
for (var i = 0; i < sides; i++)
{
points[i] = new Vector2((float) (radius*Math.Cos(theta)), (float) (radius*Math.Sin(theta)));
points[i] = new Vector2((float)(radius * Math.Cos(theta)), (float)(radius * Math.Sin(theta)));
theta += step;
}
return points;
}
private static Vector2[] CreateEllipse(float rx, float ry, int sides)
{
var vertices = new Vector2[sides];
var t = 0.0;
var dt = 2.0 * Math.PI / sides;
for (var i = 0; i < sides; i++, t += dt)
{
var x = (float)(rx * Math.Cos(t));
var y = (float)(ry * Math.Sin(t));
vertices[i] = new Vector2(x, y);
}
return vertices;
}
}
}
@@ -9,7 +9,6 @@
<PackageTags>monogame extended pipeline bmfont tiled texture atlas input viewport fps shapes sprite</PackageTags>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
<PackageLicenseUrl>https://github.com/craftworkgames/MonoGame.Extended/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png</PackageIconUrl>
</PropertyGroup>
@@ -0,0 +1,121 @@
using System;
using System.IO;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Content;
using MonoGame.Extended.TextureAtlases;
using Newtonsoft.Json;
namespace MonoGame.Extended.Serialization
{
public class JsonContentTypeReader<T> : ContentTypeReader<T>
{
protected override T Read(ContentReader reader, T existingInstance)
{
var json = reader.ReadString();
using (var stringReader = new StringReader(json))
using (var jsonReader = new JsonTextReader(stringReader))
{
var serializer = new JsonSerializer();
return serializer.Deserialize<T>(jsonReader);
}
}
}
public class TextureAtlasJsonContentTypeReader : JsonContentTypeReader<TextureAtlas>
{
private TexturePackerFile Load(ContentReader reader)
{
var json = reader.ReadString();
using (var stringReader = new StringReader(json))
using (var jsonReader = new JsonTextReader(stringReader))
{
var serializer = new JsonSerializer();
return serializer.Deserialize<TexturePackerFile>(jsonReader);
}
}
protected override TextureAtlas Read(ContentReader reader, TextureAtlas existingInstance)
{
var texturePackerFile = Load(reader);
var assetName = reader.GetRelativeAssetName(texturePackerFile.Metadata.Image);
var texture = reader.ContentManager.Load<Texture2D>(assetName);
var atlas = new TextureAtlas(assetName, texture);
var regionCount = texturePackerFile.Regions.Count;
for (var i = 0; i < regionCount; i++)
{
atlas.CreateRegion(
ContentReaderExtensions.RemoveExtension(texturePackerFile.Regions[i].Filename),
texturePackerFile.Regions[i].Frame.X,
texturePackerFile.Regions[i].Frame.Y,
texturePackerFile.Regions[i].Frame.Width,
texturePackerFile.Regions[i].Frame.Height);
}
return atlas;
}
}
//public abstract class JsonContentTypeReader<TInput, TOutput> : ContentTypeReader<TOutput>
//{
// protected abstract TOutput OnDeserialize(ContentReader reader, TInput texturePackerFile);
// protected override TOutput Read(ContentReader reader, TOutput existingInstance)
// {
// var json = reader.ReadString();
// using (var stringReader = new StringReader(json))
// using (var jsonReader = new JsonTextReader(stringReader))
// {
// var serializer = new JsonSerializer();
// var input = serializer.Deserialize<TInput>(jsonReader);
// return OnDeserialize(reader, input);
// }
// }
//}
//public class JsonContentTypeReader : ContentTypeReader
//{
// public JsonContentTypeReader(string blah) : base(typeof(object))
// {
// }
// protected override void Initialize(ContentTypeReaderManager manager)
// {
// base.Initialize(manager);
// }
// protected override object Read(ContentReader input, object existingInstance)
// {
// return null;
// }
//}
//public class TexturePackerJsonContentTypeReader : JsonContentTypeReader<TexturePackerFile, TextureAtlas>
//{
// protected override TextureAtlas OnDeserialize(ContentReader reader, TexturePackerFile texturePackerFile)
// {
// var assetName = reader.GetRelativeAssetName(texturePackerFile.Metadata.Image);
// var texture = reader.ContentManager.Load<Texture2D>(assetName);
// var atlas = new TextureAtlas(assetName, texture);
// var regionCount = texturePackerFile.Regions.Count;
// for (var i = 0; i < regionCount; i++)
// {
// atlas.CreateRegion(
// ContentReaderExtensions.RemoveExtension(texturePackerFile.Regions[i].Filename),
// texturePackerFile.Regions[i].Frame.X,
// texturePackerFile.Regions[i].Frame.Y,
// texturePackerFile.Regions[i].Frame.Width,
// texturePackerFile.Regions[i].Frame.Height);
// }
// return atlas;
// }
//}
}
@@ -11,20 +11,4 @@ namespace MonoGame.Extended.TextureAtlases
[JsonProperty("meta")]
public TexturePackerMeta Metadata { get; set; }
}
//public class TexturePackerToTextureAtlasConverter
//{
// public TextureAtlas Convert(TexturePackerFile texturePackerFile)
// {
// var name = texturePackerFile.Metadata.Image;
// var textureAtlas = new TextureAtlas(name, texture);
// foreach (var region in texturePackerFile.Regions)
// {
// textureAtlas.CreateRegion(region.Filename, region.Frame.X, region.Frame.Y, region.Frame.Width, region.Frame.Height);
// }
// return textureAtlas;
// }
//}
}
@@ -27,7 +27,7 @@ namespace MonoGame.Extended.TextureAtlases
public override string ToString()
{
return string.Format("{0} {1}", Filename, Frame);
return $"{Filename} {Frame}";
}
}
}
+130
View File
@@ -323,4 +323,134 @@ namespace MonoGame.Extended
return $"Position: {Position}, Rotation: {Rotation}, Scale: {Scale}";
}
}
/// <summary>
/// Represents the position, rotation, and scale of a three-dimensional game object.
/// </summary>
/// <seealso cref="BaseTransform{Matrix}" />
/// <remarks>
/// <para>
/// Every game object has a transform which is used to store and manipulate the position, rotation and scale
/// of the object. Every transform can have a parent, which allows to apply position, rotation and scale to game
/// objects hierarchically.
/// </para>
/// </remarks>
class Transform3 : BaseTransform<Matrix> {
private Vector3 _position;
private Quaternion _rotation;
private Vector3 _scale = Vector3.One;
public Transform3(Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null) {
Position = position ?? Vector3.Zero;
Rotation = rotation ?? Quaternion.Identity;
Scale = scale ?? Vector3.One;
}
/// <summary>
/// Gets the world position.
/// </summary>
/// <value>
/// The world position.
/// </value>
public Vector3 WorldPosition => WorldMatrix.Translation;
/// <summary>
/// Gets the world scale.
/// </summary>
/// <value>
/// The world scale.
/// </value>
public Vector3 WorldScale {
get {
Vector3 scale = Vector3.Zero;
Quaternion rotation = Quaternion.Identity;
Vector3 translation = Vector3.Zero;
WorldMatrix.Decompose(out scale, out rotation, out translation);
return scale;
}
}
/// <summary>
/// Gets the world rotation quaternion in radians.
/// </summary>
/// <value>
/// The world rotation quaternion in radians.
/// </value>
public Quaternion WorldRotation {
get {
Vector3 scale = Vector3.Zero;
Quaternion rotation = Quaternion.Identity;
Vector3 translation = Vector3.Zero;
WorldMatrix.Decompose(out scale, out rotation, out translation);
return rotation;
}
}
/// <summary>
/// Gets or sets the local position.
/// </summary>
/// <value>
/// The local position.
/// </value>
public Vector3 Position {
get { return _position; }
set {
_position = value;
LocalMatrixBecameDirty();
WorldMatrixBecameDirty();
}
}
/// <summary>
/// Gets or sets the local rotation quaternion in radians.
/// </summary>
/// <value>
/// The local rotation quaternion in radians.
/// </value>
public Quaternion Rotation {
get { return _rotation; }
set {
_rotation = value;
LocalMatrixBecameDirty();
WorldMatrixBecameDirty();
}
}
/// <summary>
/// Gets or sets the local scale.
/// </summary>
/// <value>
/// The local scale.
/// </value>
public Vector3 Scale {
get { return _scale; }
set {
_scale = value;
LocalMatrixBecameDirty();
WorldMatrixBecameDirty();
}
}
protected internal override void RecalculateWorldMatrix(ref Matrix localMatrix, out Matrix matrix) {
if (Parent != null) {
Parent.GetWorldMatrix(out matrix);
Matrix.Multiply(ref localMatrix, ref matrix, out matrix);
}
else {
matrix = localMatrix;
}
}
protected internal override void RecalculateLocalMatrix(out Matrix matrix) {
matrix = Matrix.CreateScale(_scale) *
Matrix.CreateFromQuaternion(_rotation) *
Matrix.CreateTranslation(_position);
}
public override string ToString() {
return $"Position: {Position}, Rotation: {Rotation}, Scale: {Scale}";
}
}
}
@@ -15,60 +15,26 @@ namespace MonoGame.Extended.ViewportAdapters
public class BoxingViewportAdapter : ScalingViewportAdapter
{
private readonly GraphicsDeviceManager _graphicsDeviceManager;
private readonly GameWindow _window;
private readonly GraphicsDevice _graphicsDevice;
/// <summary>
/// Initializes a new instance of the <see cref="BoxingViewportAdapter" />.
/// Note: If you're using DirectX please use the other constructor due to a bug in MonoGame.
/// https://github.com/mono/MonoGame/issues/4018
/// Initializes a new instance of the <see cref="BoxingViewportAdapter" />.
/// </summary>
public BoxingViewportAdapter(GameWindow window, GraphicsDevice graphicsDevice, int virtualWidth,
int virtualHeight, int horizontalBleed, int verticalBleed)
public BoxingViewportAdapter(GameWindow window, GraphicsDevice graphicsDevice, int virtualWidth, int virtualHeight, int horizontalBleed = 0, int verticalBleed = 0)
: base(graphicsDevice, virtualWidth, virtualHeight)
{
_window = window;
_graphicsDevice = graphicsDevice;
window.ClientSizeChanged += OnClientSizeChanged;
HorizontalBleed = horizontalBleed;
VerticalBleed = verticalBleed;
}
/// <summary>
/// Initializes a new instance of the <see cref="BoxingViewportAdapter" />.
/// Note: If you're using DirectX please use the other constructor due to a bug in MonoGame.
/// https://github.com/mono/MonoGame/issues/4018
/// </summary>
public BoxingViewportAdapter(GameWindow window, GraphicsDevice graphicsDevice, int virtualWidth,
int virtualHeight)
: this(window, graphicsDevice, virtualWidth, virtualHeight, 0, 0)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BoxingViewportAdapter" />.
/// Use this constructor only if you're using DirectX due to a bug in MonoGame.
/// https://github.com/mono/MonoGame/issues/4018
/// This constructor will be made obsolete and eventually removed once the bug has been fixed.
/// </summary>
public BoxingViewportAdapter(GameWindow window, GraphicsDeviceManager graphicsDeviceManager, int virtualWidth,
int virtualHeight, int horizontalBleed, int verticalBleed)
: this(
window, graphicsDeviceManager.GraphicsDevice, virtualWidth, virtualHeight, horizontalBleed,
verticalBleed)
{
_graphicsDeviceManager = graphicsDeviceManager;
}
/// <summary>
/// Initializes a new instance of the <see cref="BoxingViewportAdapter" />.
/// Use this constructor only if you're using DirectX due to a bug in MonoGame.
/// https://github.com/mono/MonoGame/issues/4018
/// This constructor will be made obsolete and eventually removed once the bug has been fixed.
/// </summary>
public BoxingViewportAdapter(GameWindow window, GraphicsDeviceManager graphicsDeviceManager, int virtualWidth,
int virtualHeight)
: this(window, graphicsDeviceManager, virtualWidth, virtualHeight, 0, 0)
public override void Dispose()
{
_window.ClientSizeChanged -= OnClientSizeChanged;
base.Dispose();
}
/// <summary>
@@ -85,45 +51,34 @@ namespace MonoGame.Extended.ViewportAdapters
private void OnClientSizeChanged(object sender, EventArgs eventArgs)
{
var viewport = GraphicsDevice.Viewport;
var clientBounds = _window.ClientBounds;
var worldScaleX = (float) viewport.Width/VirtualWidth;
var worldScaleY = (float) viewport.Height/VirtualHeight;
var worldScaleX = (float)clientBounds.Width / VirtualWidth;
var worldScaleY = (float)clientBounds.Height / VirtualHeight;
var safeScaleX = (float) viewport.Width/(VirtualWidth - HorizontalBleed);
var safeScaleY = (float) viewport.Height/(VirtualHeight - VerticalBleed);
var safeScaleX = (float)clientBounds.Width / (VirtualWidth - HorizontalBleed);
var safeScaleY = (float)clientBounds.Height / (VirtualHeight - VerticalBleed);
var worldScale = MathHelper.Max(worldScaleX, worldScaleY);
var safeScale = MathHelper.Min(safeScaleX, safeScaleY);
var scale = MathHelper.Min(worldScale, safeScale);
var width = (int) (scale*VirtualWidth + 0.5f);
var height = (int) (scale*VirtualHeight + 0.5f);
var width = (int)(scale * VirtualWidth + 0.5f);
var height = (int)(scale * VirtualHeight + 0.5f);
if ((height >= viewport.Height) && (width < viewport.Width))
if (height >= clientBounds.Height && width < clientBounds.Width)
BoxingMode = BoxingMode.Pillarbox;
else
{
if ((width >= viewport.Height) && (height < viewport.Height))
if (width >= clientBounds.Height && height <= clientBounds.Height)
BoxingMode = BoxingMode.Letterbox;
else
else
BoxingMode = BoxingMode.None;
}
var x = viewport.Width/2 - width/2;
var y = viewport.Height/2 - height/2;
var x = clientBounds.Width / 2 - width / 2;
var y = clientBounds.Height / 2 - height / 2;
GraphicsDevice.Viewport = new Viewport(x, y, width, height);
// Needed for a DirectX bug in MonoGame 3.4. Hopefully it will be fixed in future versions
// see http://gamedev.stackexchange.com/questions/68914/issue-with-monogame-resizing
if ((_graphicsDeviceManager != null) &&
((_graphicsDeviceManager.PreferredBackBufferWidth != _window.ClientBounds.Width) ||
(_graphicsDeviceManager.PreferredBackBufferHeight != _window.ClientBounds.Height)))
{
_graphicsDeviceManager.PreferredBackBufferWidth = _window.ClientBounds.Width;
_graphicsDeviceManager.PreferredBackBufferHeight = _window.ClientBounds.Height;
_graphicsDeviceManager.ApplyChanges();
}
}
public override void Reset()
@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
// ReSharper disable once CheckNamespace
namespace MonoGame.Extended.ViewportAdapters
{
public class ScalingViewportAdapter : ViewportAdapter
@@ -1,17 +1,20 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
// ReSharper disable once CheckNamespace
namespace MonoGame.Extended.ViewportAdapters
{
public abstract class ViewportAdapter
public abstract class ViewportAdapter : IDisposable
{
protected ViewportAdapter(GraphicsDevice graphicsDevice)
{
GraphicsDevice = graphicsDevice;
}
public virtual void Dispose()
{
}
public GraphicsDevice GraphicsDevice { get; }
public Viewport Viewport => GraphicsDevice.Viewport;