Skip to content

Commit 8eba613

Browse files
committed
Read directly from ase/aseprite file
1 parent 55c1109 commit 8eba613

File tree

118 files changed

+5738
-5097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+5738
-5097
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28010.2026
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30523.141
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Aseprite.Demo", "MonoGame.Aseprite.Demo\MonoGame.Aseprite.Demo.csproj", "{E913F2A2-68AE-4DEE-80FD-9C0DCD5F2B03}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Aseprite.Demo", "MonoGame.Aseprite.Demo\MonoGame.Aseprite.Demo.csproj", "{053CF0AF-DE86-4546-B824-678E1B1B6BCF}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{E913F2A2-68AE-4DEE-80FD-9C0DCD5F2B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{E913F2A2-68AE-4DEE-80FD-9C0DCD5F2B03}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{E913F2A2-68AE-4DEE-80FD-9C0DCD5F2B03}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{E913F2A2-68AE-4DEE-80FD-9C0DCD5F2B03}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{053CF0AF-DE86-4546-B824-678E1B1B6BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{053CF0AF-DE86-4546-B824-678E1B1B6BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{053CF0AF-DE86-4546-B824-678E1B1B6BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{053CF0AF-DE86-4546-B824-678E1B1B6BCF}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {20BF91DD-8F9F-459C-BBAF-64E3EF5B5F45}
23+
SolutionGuid = {A0A06042-1020-4BEE-9F8F-549FBCBA83C0}
2424
EndGlobalSection
2525
EndGlobal
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#----------------------------- Global Properties ----------------------------#
3+
4+
/outputDir:bin/$(Platform)
5+
/intermediateDir:obj/$(Platform)
6+
/platform:DesktopGL
7+
/config:
8+
/profile:HiDef
9+
/compress:False
10+
11+
#-------------------------------- References --------------------------------#
12+
13+
/reference:..\..\..\source\MonoGame.Aseprite.ContentPipeline\bin\Debug\netstandard2.0\MonoGame.Aseprite.ContentPipeline.dll
14+
15+
#---------------------------------- Content ---------------------------------#
16+
17+
#begin ../../../../sokoban_player.aseprite
18+
/importer:AsepriteImporter
19+
/processor:AsepriteProcessor
20+
/build:../../../../sokoban_player.aseprite;sokoban_player.aseprite
21+

demo/net45/MonoGame.Aseprite.Demo/Game1.cs renamed to demo/MonoGame.Aseprite.Demo/Game1.cs

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
1-
//--------------------------------------------------------------------------------
2-
// MonoGame Aseprite Demo
3-
//
4-
// This is a demo project setup to demonstrate the usage of the
5-
// MonoGame.Aseprite.AnimatedSprite and using the MonoGame.Aseprite.ContentPipeline
6-
// to import the spritesheet and .json produced from Aseprite.
7-
//
8-
//--------------------------------------------------------------------------------
9-
//
10-
// License
11-
//
12-
// Copyright(c) 2018 Chris Whitley
13-
//
14-
// Permission is hereby granted, free of charge, to any person obtaining a copy
15-
// of this software and associated documentation files (the "Software"), to deal
16-
// in the Software without restriction, including without limitation the rights
17-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18-
// copies of the Software, and to permit persons to whom the Software is
19-
// furnished to do so, subject to the following conditions:
20-
//
21-
// The above copyright notice and this permission notice shall be included in
22-
// all copies or substantial portions of the Software.
23-
//
24-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30-
// THE SOFTWARE.
31-
//--------------------------------------------------------------------------------
32-
33-
using Microsoft.Xna.Framework;
1+
using Microsoft.Xna.Framework;
342
using Microsoft.Xna.Framework.Graphics;
353
using Microsoft.Xna.Framework.Input;
364

@@ -42,14 +10,17 @@ public class Game1 : Game
4210
SpriteBatch spriteBatch;
4311

4412
Player _player;
45-
13+
14+
15+
16+
AsepriteImportResult _aseprite;
17+
4618
public Game1()
4719
{
4820
graphics = new GraphicsDeviceManager(this);
4921
Content.RootDirectory = "Content";
5022

51-
graphics.PreferredBackBufferWidth = 1280;
52-
graphics.PreferredBackBufferHeight = 720;
23+
5324
}
5425

5526
/// <summary>
@@ -64,6 +35,10 @@ protected override void Initialize()
6435

6536
base.Initialize();
6637

38+
graphics.PreferredBackBufferWidth = 1280;
39+
graphics.PreferredBackBufferHeight = 720;
40+
graphics.ApplyChanges();
41+
6742
// Inilize the Draw utilit so we can draw the hollow rectangles
6843
Utils.Draw.Initilize(GraphicsDevice);
6944
}
@@ -80,7 +55,6 @@ protected override void LoadContent()
8055
// TODO: use this.Content to load your game content here
8156
_player = new Player(new Vector2(1280, 720) * 0.5f);
8257
_player.LoadContent(this.Content);
83-
8458
}
8559

8660
/// <summary>
@@ -106,6 +80,7 @@ protected override void Update(GameTime gameTime)
10680
protected override void Draw(GameTime gameTime)
10781
{
10882
GraphicsDevice.Clear(new Color(51, 153, 218));
83+
10984

11085
// TODO: Add your drawing code here
11186

File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
2525
</ItemGroup>
2626
<ItemGroup>
27-
<PackageReference Include="MonoGame.Aseprite" Version="1.2.2" />
2827
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
2928
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
3029
</ItemGroup>
30+
<ItemGroup>
31+
<ProjectReference Include="..\..\source\MonoGame.Aseprite\MonoGame.Aseprite.csproj" />
32+
</ItemGroup>
3133
</Project>

demo/net45/MonoGame.Aseprite.Demo/Player.cs renamed to demo/MonoGame.Aseprite.Demo/Player.cs

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
1-
//--------------------------------------------------------------------------------
2-
// Player
3-
//
4-
// This is a simple player class that makes use of MonoGame.Aseprite.AnimatedSprite
5-
// in order to render the player with animations
6-
//
7-
//--------------------------------------------------------------------------------
8-
//
9-
// License
10-
//
11-
// Copyright(c) 2018 Chris Whitley
12-
//
13-
// Permission is hereby granted, free of charge, to any person obtaining a copy
14-
// of this software and associated documentation files (the "Software"), to deal
15-
// in the Software without restriction, including without limitation the rights
16-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17-
// copies of the Software, and to permit persons to whom the Software is
18-
// furnished to do so, subject to the following conditions:
19-
//
20-
// The above copyright notice and this permission notice shall be included in
21-
// all copies or substantial portions of the Software.
22-
//
23-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29-
// THE SOFTWARE.
30-
//--------------------------------------------------------------------------------
31-
32-
33-
using Microsoft.Xna.Framework;
1+
using Microsoft.Xna.Framework;
342
using Microsoft.Xna.Framework.Content;
353
using Microsoft.Xna.Framework.Graphics;
364
using Microsoft.Xna.Framework.Input;
@@ -51,7 +19,7 @@ public class Player
5119
Vector2 _currentDirection = Vector2.UnitY;
5220

5321

54-
22+
5523

5624

5725
/// <summary>
@@ -64,7 +32,7 @@ public Vector2 Position
6432
{
6533
if (this._position == value) { return; }
6634
this._position = value;
67-
if(_sprite != null)
35+
if (_sprite != null)
6836
{
6937
_sprite.Position = value;
7038
}
@@ -91,9 +59,11 @@ public Player(Vector2 position)
9159
/// <param name="content"></param>
9260
public void LoadContent(ContentManager content)
9361
{
94-
AnimationDefinition animationDefinition = content.Load<AnimationDefinition>("playerAnimation");
95-
Texture2D texture = content.Load<Texture2D>("player");
96-
_sprite = new AnimatedSprite(texture, animationDefinition, this.Position);
62+
AsepriteImportResult aseprite = content.Load<AsepriteImportResult>("sokoban_player");
63+
_sprite = new AnimatedSprite(aseprite, Position);
64+
//AnimationDefinition animationDefinition = content.Load<AnimationDefinition>("playerAnimation");
65+
//Texture2D texture = content.Load<Texture2D>("player");
66+
//_sprite = new AnimatedSprite(texture, animationDefinition, this.Position);
9767

9868
}
9969

@@ -130,36 +100,36 @@ private void UpdateInput(GameTime gameTime)
130100
// Move up
131101
this._currentDirection = Vector2.UnitY * -1;
132102
this.Position += this._currentDirection * _speed * delatTime;
133-
this._sprite.Play("walk up");
103+
this._sprite.Play("walk_up");
134104
}
135105
else if (Keyboard.GetState().IsKeyDown(Keys.Down) || Keyboard.GetState().IsKeyDown(Keys.S))
136106
{
137107
// Move down
138108
this._currentDirection = Vector2.UnitY;
139109
this.Position += this._currentDirection * _speed * delatTime;
140-
this._sprite.Play("walk down");
110+
this._sprite.Play("walk_down");
141111
}
142112
else if (Keyboard.GetState().IsKeyDown(Keys.Left) || Keyboard.GetState().IsKeyDown(Keys.A))
143113
{
144114
// Move left
145115
this._currentDirection = Vector2.UnitX * -1;
146116
this.Position += this._currentDirection * _speed * delatTime;
147-
this._sprite.Play("walk left");
117+
this._sprite.Play("walk_left");
148118
}
149119
else if (Keyboard.GetState().IsKeyDown(Keys.Right) || Keyboard.GetState().IsKeyDown(Keys.D))
150120
{
151121
// Move right
152122
this._currentDirection = Vector2.UnitX;
153123
this.Position += this._currentDirection * _speed * delatTime;
154-
this._sprite.Play("walk right");
124+
this._sprite.Play("walk_right");
155125
}
156126
else
157127
{
158128
// No movement, so use the current direction value to set the idle animation
159-
if (this._currentDirection == Vector2.UnitY * -1) { this._sprite.Play("idle up"); }
160-
else if (this._currentDirection == Vector2.UnitY) { this._sprite.Play("idle down"); }
161-
else if (this._currentDirection == Vector2.UnitX * -1) { this._sprite.Play("idle left"); }
162-
else if (this._currentDirection == Vector2.UnitX) { this._sprite.Play("idle right"); }
129+
if (this._currentDirection == Vector2.UnitY * -1) { this._sprite.Play("idle_up"); }
130+
else if (this._currentDirection == Vector2.UnitY) { this._sprite.Play("idle_down"); }
131+
else if (this._currentDirection == Vector2.UnitX * -1) { this._sprite.Play("idle_left"); }
132+
else if (this._currentDirection == Vector2.UnitX) { this._sprite.Play("idle_right"); }
163133

164134
}
165135
}
@@ -175,32 +145,32 @@ public void Render(SpriteBatch spriteBatch)
175145

176146
// Get the slice rectangle for the current frame. The name passed
177147
// must be the same as the name of the slice in Aseprite
178-
var bodyHitBox = this._sprite.GetCurrentFrameSlice("body-hit-box");
179-
var hatHitBox = this._sprite.GetCurrentFrameSlice("hat-hit-box");
180-
var footHitBox = this._sprite.GetCurrentFrameSlice("foot-on-ground-hitbox");
148+
var bodyHitBox = this._sprite.GetCurrentFrameSlice("body_hitbox");
149+
var hatHitBox = this._sprite.GetCurrentFrameSlice("hat_hitbox");
150+
//var footHitBox = this._sprite.GetCurrentFrameSlice("foot-on-ground-hitbox");
181151

182152
// Check if there is a value. We have to check since the return above is a nullable Rectangle.
183153
// If it doesn't have a value, that means there was no SliceKey defined for the current frame of
184154
// animation for the slice
185-
if(bodyHitBox.HasValue)
155+
if (bodyHitBox.HasValue)
186156
{
187157
// If you want to use the same colors you used in Aseprite for the color of the slice
188158
// you can retrive that like this
189-
Color sliceColor = this._sprite.GetSliceColor("body-hit-box");
159+
Color sliceColor = this._sprite.GetSliceColor("body_hitbox");
190160
spriteBatch.DrawHollowRectangle(bodyHitBox.Value, sliceColor);
191161
}
192162

193-
if(hatHitBox.HasValue)
163+
if (hatHitBox.HasValue)
194164
{
195-
Color sliceColor = this._sprite.GetSliceColor("hat-hit-box");
165+
Color sliceColor = this._sprite.GetSliceColor("hat_hitbox");
196166
spriteBatch.DrawHollowRectangle(hatHitBox.Value, sliceColor);
197167
}
198168

199-
if(footHitBox.HasValue)
200-
{
201-
Color sliceColor = this._sprite.GetSliceColor("foot-on-ground-hitbox");
202-
spriteBatch.DrawHollowRectangle(footHitBox.Value, sliceColor);
203-
}
169+
//if (footHitBox.HasValue)
170+
//{
171+
// Color sliceColor = this._sprite.GetSliceColor("foot-on-ground-hitbox");
172+
// spriteBatch.DrawHollowRectangle(footHitBox.Value, sliceColor);
173+
//}
204174
}
205175
}
206176
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
3+
namespace MonoGame.Aseprite.Demo
4+
{
5+
public static class Program
6+
{
7+
[STAThread]
8+
static void Main()
9+
{
10+
using (var game = new Game1())
11+
game.Run();
12+
}
13+
}
14+
}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
using Microsoft.Xna.Framework;
1+
using System;
2+
using Microsoft.Xna.Framework;
23
using Microsoft.Xna.Framework.Graphics;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
84

95
namespace MonoGame.Aseprite.Demo.Utils
106
{
@@ -21,7 +17,7 @@ public static void Initilize(GraphicsDevice graphicsDevice)
2117
int pixelHeight = 2;
2218
_pixel = new Texture2D(graphicsDevice, pixelWidth, pixelHeight);
2319
Color[] colors = new Color[pixelWidth * pixelHeight];
24-
for(int i = 0; i < pixelWidth * pixelHeight; i++)
20+
for (int i = 0; i < pixelWidth * pixelHeight; i++)
2521
{
2622
colors[i] = Color.White;
2723
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3-
<assemblyIdentity version="1.0.0.0" name="Monogame.Aseprite.Demo"/>
3+
<assemblyIdentity version="1.0.0.0" name="MonoGame.Aseprite.Demo"/>
44
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
55
<security>
66
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

0 commit comments

Comments
 (0)