Skip to content

Commit

Permalink
Add Size to DrawInfo Component
Browse files Browse the repository at this point in the history
  • Loading branch information
roo-oliv committed Apr 5, 2024
1 parent fa134ab commit ed27508
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: allrod5
github: roo-oliv
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("MonoDreams.Tests")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4fc8b1926a91e241177675f4e1acd4b3df72cca6")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fa134abf0db55e8ac084d652e9007c0c528d9f42")]
[assembly: System.Reflection.AssemblyProductAttribute("MonoDreams.Tests")]
[assembly: System.Reflection.AssemblyTitleAttribute("MonoDreams.Tests")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e68c4eaa0fcc1c25d66de76d35646dde2725a12f686b32cd94543a38f3d9e0d7
247bb53ef5ceecb041c4257fde7b901a44d7710457980b3a1fd2a5c3dcf69033
2 changes: 1 addition & 1 deletion MonoDreams.Tests/obj/rider.project.model.nuget.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17122612918497350
17122646510223614
2 changes: 1 addition & 1 deletion MonoDreams.Tests/obj/rider.project.restore.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17122612894097984
17122646510223614
15 changes: 5 additions & 10 deletions MonoDreams/Component/DrawInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ namespace MonoDreams.Component;
public struct DrawInfo
{
public Texture2D SpriteSheet;
public Point Size;
public Rectangle Source;
public Color Color;

public DrawInfo(Texture2D spriteSheet, Rectangle source, Color color)
public DrawInfo(Texture2D spriteSheet, Point? size = null, Rectangle? source = null, Color? color = null)
{
SpriteSheet = spriteSheet;
Source = source;
Color = color;
}

public DrawInfo(Texture2D texture, Color? color = null)
{
SpriteSheet = texture;
Source = texture.Bounds;
Color = color ?? Color.White;
Size = size ?? spriteSheet.Bounds.Size;
Source = source ?? spriteSheet.Bounds;
Color = color ?? Color.White;
}
}
2 changes: 1 addition & 1 deletion MonoDreams/MonoDreams.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PropertyGroup>
<Authors>Rodrigo Oliveira</Authors>
<Description>
MonoDreams is a simple 2D game engine written in C# using the MonoGame framework. It is designed to be easy to use and to provide a simple way to create 2D games.
A code-first and data-driven opensource 2D game engine powered by MonoGame
</Description>
<PackageProjectUrl>https://github.com/roo-oliv/monodreams</PackageProjectUrl>
<PackageTags>game, engine, library, monogame, 2d, xna, monodreams</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion MonoDreams/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MonoDreams
==========

MonoDreams is a simple 2D game engine written in C# using the MonoGame framework. It is designed to be easy to use and to provide a simple way to create 2D games.
A code-first and data-driven opensource 2D game engine powered by MonoGame
3 changes: 2 additions & 1 deletion MonoDreams/System/DrawSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected override void Update(GameState state, in Entity entity)
drawInfo.Source = new Rectangle(frameWidth * animation.CurrentFrame, 0, frameWidth, drawInfo.SpriteSheet.Height);
}

_batch.Draw(drawInfo.SpriteSheet, position.CurrentLocation, drawInfo.Source, drawInfo.Color);
var destination = new Rectangle(position.CurrentLocation.ToPoint(), drawInfo.Size);
_batch.Draw(drawInfo.SpriteSheet, destination, drawInfo.Source, drawInfo.Color);
}

protected override void PostUpdate(GameState state) => _batch.End();
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MonoDreams
<br>
</p>
<p align="center">
A powerful, flexible, and free 2D game engine powered by MonoGame
A code-first and data-driven opensource 2D game engine powered by MonoGame
</p>

![NuGet Version](https://img.shields.io/nuget/vpre/MonoDreams?link=https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMonoDreams%2F)
Expand All @@ -18,8 +18,9 @@ A powerful, flexible, and free 2D game engine powered by MonoGame
This is a hobby project of mine.

With no roadmap commitment, this project's goal is to create an opensource 2D game engine on top of Monogame and DefaultECS loaded with common systems for 2D games such as input handling, HUD, dialogue system, camera movement, sprite renderer, level importer, gravity and jumping logics, AABB collision detection and resolution, and more.
MonoDreams is designed to be a code-first and data-driven engine, with a focus on ease of use and flexibility.

[You can follow my tentative roadmap here.](https://github.com/users/allrod5/projects/1/views/1)
[You can follow my tentative roadmap here.](https://github.com/users/roo-oliv/projects/1/views/1)

# Special Thanks
This project is intended to support and enable the gamedev community and I hope one day it will be a good starting point for many people to create their own games.
Expand Down

0 comments on commit ed27508

Please sign in to comment.