Skip to content

Commit

Permalink
sprite sheet animation example
Browse files Browse the repository at this point in the history
  • Loading branch information
nolemretaW committed Jun 6, 2023
1 parent 260e2b4 commit 6d5a32b
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 18 deletions.
18 changes: 18 additions & 0 deletions Chroma.Shine.Examples/Animation/Animation.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Chroma.Shine\Chroma.Shine.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Chroma" Version="0.58.0" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions Chroma.Shine.Examples/Animation/GameCore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Numerics;
using Chroma;
using Chroma.ContentManagement;
using Chroma.ContentManagement.FileSystem;
using Chroma.Graphics;

namespace Animation
{
public class GameCore : Game
{
private SpriteSheet _spriteSheet;
private SpriteSheetAnimation _spriteSheetAnimation;

public GameCore() : base(new(false, false))
{

}

protected override IContentProvider InitializeContentPipeline()
{
return new FileSystemContentProvider(
Path.Combine(AppContext.BaseDirectory, "../../../../_common")
);
}

protected override void LoadContent()
{
_spriteSheet = new SpriteSheet(Content.Load<Texture>("Textures/Spritesheet.png"), 128, 128);
_spriteSheet.Position = new Vector2(30, 40);
_spriteSheetAnimation = new SpriteSheetAnimation(_spriteSheet, 1, 24, 0.5f);
_spriteSheetAnimation.Repeat = true;
_spriteSheetAnimation.Play();
}

protected override void Update(float delta)
{
_spriteSheetAnimation.Update(delta);
}

protected override void Draw(RenderContext context)
{
_spriteSheetAnimation.Draw(context);
}
}
}
3 changes: 3 additions & 0 deletions Chroma.Shine.Examples/Animation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Animation;

new GameCore().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Chroma.Shine\Chroma.Shine.csproj" />
<ProjectReference Include="..\..\Chroma.Shine\Chroma.Shine.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Numerics;
using Chroma;
using Chroma.Diagnostics.Logging;
using Chroma.Graphics;
using Chroma.Input;
using Chroma.Physics;

namespace Chroma.ShineExample
namespace Collision
{
internal class GameCore : Game
{
Expand Down
3 changes: 3 additions & 0 deletions Chroma.Shine.Examples/Collision/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Collision;

new GameCore().Run();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 19 additions & 7 deletions Chroma.Shine.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chroma.Shine", "Chroma.Shine\Chroma.Shine.csproj", "{EB381EC6-BB2A-4DAC-AD02-E067D0017C97}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chroma.ShineExample", "Chroma.ShineExample\Chroma.ShineExample.csproj", "{A7644344-BF3C-4133-B3B7-0261D6AD459E}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chroma.Shine.Examples", "Chroma.Shine.Examples", "{1D88FC4A-ECFC-4736-8A32-F68C0C50A606}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Collision", "Chroma.Shine.Examples\Collision\Collision.csproj", "{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animation", "Chroma.Shine.Examples\Animation\Animation.csproj", "{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,14 +21,22 @@ Global
{EB381EC6-BB2A-4DAC-AD02-E067D0017C97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB381EC6-BB2A-4DAC-AD02-E067D0017C97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB381EC6-BB2A-4DAC-AD02-E067D0017C97}.Release|Any CPU.Build.0 = Release|Any CPU
{A7644344-BF3C-4133-B3B7-0261D6AD459E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7644344-BF3C-4133-B3B7-0261D6AD459E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7644344-BF3C-4133-B3B7-0261D6AD459E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7644344-BF3C-4133-B3B7-0261D6AD459E}.Release|Any CPU.Build.0 = Release|Any CPU
{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2}.Release|Any CPU.Build.0 = Release|Any CPU
{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{477E1ADE-9B2E-4AD9-915A-FE0237AF75E2} = {1D88FC4A-ECFC-4736-8A32-F68C0C50A606}
{2E84EE54-31F8-4B88-9EDF-5AD6D71AAE0F} = {1D88FC4A-ECFC-4736-8A32-F68C0C50A606}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {96618996-708A-487E-AB1F-B87A39121708}
EndGlobalSection
Expand Down
9 changes: 0 additions & 9 deletions Chroma.ShineExample/Program.cs

This file was deleted.

0 comments on commit 6d5a32b

Please sign in to comment.