DaveGreen.ShapeEngine 2.4.0

Prefix Reserved
dotnet add package DaveGreen.ShapeEngine --version 2.4.0                
NuGet\Install-Package DaveGreen.ShapeEngine -Version 2.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DaveGreen.ShapeEngine" Version="2.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DaveGreen.ShapeEngine --version 2.4.0                
#r "nuget: DaveGreen.ShapeEngine, 2.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DaveGreen.ShapeEngine as a Cake Addin
#addin nuget:?package=DaveGreen.ShapeEngine&version=2.4.0

// Install DaveGreen.ShapeEngine as a Cake Tool
#tool nuget:?package=DaveGreen.ShapeEngine&version=2.4.0                

My custom-made engine based on the great Raylib Framework. The Main focus is being performant and only using draw functions instead of textures.

When using Shape Engine everything from Raylib is available as well. (Raylib ExamplesRaylib Cheatsheet)

Shape Engine´s examples are available on Itch as well and it is a great way to support me 😉

You are free to use Shape Engine or any part of Shape Engine for your own projects, but keep in mind that Shape Engine was designed to help me with my specific game dev needs. Nevertheless I am looking forward to creations that Shape Engine made possible 😃

Release Trailer

Development Process

The Main Branch contains the current development stage. You can follow the development process here:

Installation / How to Use

There are multiple ways to use Shape Engine:

  1. Create a new solution & project and download Shape Engine from the Nuget manager. (Recommended)
  2. Clone or fork the repository and add new projects to the solution. You then can reference the Shape Engine project and start working on your game. The advantages are that you can easily change things in Shape Engine and everything updates automatically in your own project.
  3. Create a new solution & project in a .net IDE. (Visual Studio / JetBrains Rider for example). Download or fork ShapeEngine and either create a local nuget package or build the solution to create all necessary dll files.
  4. [Using a local Nuget Package] Create a folder on your machine called something like “Local Nuget Packages” and copy the ShapeEngine Nuget package that you created to this folder. (You can also add the Shape Engine Nuget package directly to your Project). Now you need to create a new Package source in the Nuget Manager that points to your “Local Nuget Packages” Folder. This source can be used in your Nuget Manager to find and install the Shape Engine Nuget Package.
  5. You manually copy all needed DLL files to your project. You need the following DLLs: Clipper2Lib, Raylib-Cs, Microsoft.Toolkit.HighPerformance, Shape Engine Core, Raylib. All DLL files except Raylib can be anywhere in your projects folder hierarchy. The Raylib DLL must be on the root level of your project. You need to select the right Raylib DLL for your operating system. Now just add a reference for all DLLs except the Raylib DLL and you are done. On MacOS you need to do the same step except using the .dylib file instead of the raylib DLL. You need to set the property “Copy if Newer” to true on the .dylib file. Then everything should work.
  6. Create a new solution & project and just add the Shape Engine Core DLL to your project and reference it. Now you need to download the right version of the Raylib_CsLo & Clipper2 Nuget packages. The releases on GitHub will state which versions were used.

Minimal Project Setup

using System.Drawing; 
using ShapeEngine.Color; 
using ShapeEngine.Core; 
using ShapeEngine.Core.Structs; 
using ShapeEngine.Lib;  

namespace ShapeEngineProject;   

public static class Program 
{     
    public static void Main(string[] args)     
    {         
        var game = new MyGameClass(GameSettings.StretchMode, WindowSettings.Default);
		game.Run();    
    } 
} 

public class MyGameClass : Game 
{     
    public MyGameClass(GameSettings gameSettings, WindowSettings windowSettings) : base(gameSettings, windowSettings) { }     
    
    protected override void DrawGame(ScreenInfo game)     
    {         
        game.Area.Draw(new ColorRgba(Color.DarkOliveGreen));         
        game.Area.DrawLines(12f, new ColorRgba(Color.AntiqueWhite));         
        game.MousePos.Draw(24f, new ColorRgba(Color.Lime), 36);     
    } 
} 

Examples

You can download the newest builds of the Example Project on Itch io. You can clone the repo and inspect the example projects there as well.

  • Examples are simple scenes that focus on one specific area or feature of Shape Engine.
  • Examples showcase the various capabilities of Shape Engine, allowing users to explore various features.
  • The examples cover all major features of Shape Engine, ensuring that users can grasp its full potential.

Features

In general my goal is to provide the most relevant system a game dev needs without adding a solution for every possible problem.

Documentation & Getting Started

Right now there is not much information about how to use Shape Engine. The repository contains an Examples Project. It shows you a lot of what is possible and how it is done and should help you until there is some proper documentation.

Currently I don't have the time or the resources to create proper documentation for Shape Engine. If enough people are interested in it this might change. Any help in this direction would be greatly appreciated!

Roadmap

You will always find the roadmaps on ShapeEngine´s GitHub Discussion page here.

Dependencies

I am just using the Raylib Cs c# bindings and the Cipper2 library for polygon clipping.

If you use the nuget manager to download Shape Engine as a nuget package you don't have to take care of any dependencies, because they will be downloaded automatically.

Limitations

There is no physics system because I don´t need one and would´t know how to make one. There is complete collision system but the collision response is up to you. You can also use raylibs physics system.

History

I made Shape Engine because I wanted to help myself make games with a specific art style and certain limitations. At first, it started out with some helper scripts but now it is a relatively sophisticated system to make games with raylib. Certain parts of the basic game loop are inspired by Bytepath and other things I already used in games that I made myself (especially Fracture Hell). Feel free to use any single part if you don´t want to use the whole package.

Contact

If you have an issue, or a suggestion for a new feature GitHub is the best way to get in contact with me.

On these platforms you can follow the development process of Shape Engine, get in contact with me and always stay up date.

Linktree

https://linktr.ee/davegreen.games

https://linktr.ee/shapeengine

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.0 41 11/6/2024
2.3.1 84 10/23/2024
2.3.0 82 10/21/2024
2.2.0 84 10/4/2024
2.1.1 126 9/11/2024
2.1.0 90 9/8/2024
2.0.2 106 8/30/2024
2.0.1 101 8/29/2024
2.0.0 92 8/29/2024
1.0.3 148 6/5/2024
1.0.2 112 6/1/2024
1.0.1 111 5/29/2024
1.0.0 111 5/23/2024

# 2.4.0 Minor Release
- New functions to Transform2D added (UpdateTransform and GetChildTransform)
- Collider now uses UpdateTransform function
- Collider cleaned up
- ApplyTransform/ApplyTransformCopy functions changed to ApplyOffset/ApplyOffsetCopy in all shapes
- New Shape class added that inherits from IShape
- Collider now inherits from Shape instead of IShape
- ShapeContainer (Parent/Child hierarchy system for shapes) added. A ShapeContainer can have a ShapeContainer parent and any number of ShapeContainer children. The children are updated based on the parent transform and the child offsets.
- CircleShape, TriangleShape, SegmentShape, RectShape, QuadShape, PolyShape, PolyLineShape classes added. They inherit from ShapeContainer.

# 2.3.1 Hot Fix
- Game reference is now set in Scene before Activate is called on the Scene

# 2.3.0 Release
- ScreenTextures should now properly scale on macOS when an high dpi monitor is used. (Before ScreenTextures in StretchMode would be not as sharp as they should be)
- Audio Device Cleanup
- Audio Device more overloads for certain functions added
- AudioDevice PlaySFX() functions now return bool for success or failure
- Playlist improvements
- Game class now has a default AudioDevice initialized from the start
- ShapeID and IDCounter Reset() and AdvanveTo() functions added
- An active Scene now has a reference to the parent Game class that activated the Scene
- CollisionObject now can optionally report collision events like ColliderCollision() and ColliderCollisionEnded(). ReportColliderCollision must be set to true!
- Transform2d now has a Vector2 Scale2d field. The Scale field stays intact and reports the Scale2d.X value.
- Collider received are more advanced collision notification system
- Dimensions now have more operators
- AlphaCircle shader added to Examples

# 2.2.0 Release
- Segment Overlap functions fixed.
- Quad ContainsPoint function fixed. (typo was the problem)
- Polyline improvements / clean up.
- RangeFloat and RangeInt deprecated. Both classes are still available but will be removed in a future update
- ValueRange and ValueRangeInt readonly structs implemented to replace RangeFloat and RangeInt classes. They do basically the same but they are readonly structs now.

# 2.1.1 Release
- Savegame system path combining fixed.

# 2.1.0 Release
- Implemented CircleSector shape and CircleSectorCollider (useful for detection cones for instance)
- Implemented OutlinePercentage drawing for all shapes
- A few fixes and improvements.


# 2.0 Release
## Transform2D Overhaul

- Transform2D now has a scale value
- Transform2D now has a ScaledSize Getter (Size \* Scale)
- Transform2D now has Radius and Length Getters (they use Width) for circles, segments, triangles, polylines and polygons
- Transform2D is now properly used in the collider / collision system
- CollisionObject has Transform2D and each collider has an Transform2D offset which are combined to form the CurTransform of the collider
- Examples were updated to reflect the new changes (EndlessCollisionSystem, AsteroidMiningExample, GameObjectHandlerExample, and BouncyCircles)
- Transform2D lerp functions added

## Screen Texture 2.0

- Screen Texture has different modes to draw the texture to the screen now:
- `Stretch Mode`, the texture will always be the same size as the screen
- `Pixelation Mode`, the texture will always be the same aspect ratio as the screen but scaled down by a certain factor (0 - 1 range)
- `Fixed Mode`, the texture will always stay at the same (specified) size and will be centered on the screen and upscaled to the closest dimension of the screen with black bars on the other dimension if necessary.
- `Nearest Fixed Mode`, the texture will always be the same aspect ratio as the screen (no black bars) but will stay as close as possible to the fixed dimension. 
- `Anchor Mode`, a anchor position and stretch value can be specified to position the screen texture anywhere on the screen. This can be useful for splitscreen or minimaps.
- `Custom Mode` , the user can control the size of texture, the mouse scaling and how the texture is drawn to the screen.
- Mouse Position Scaling works for all modes and the screen texture reports the scaled mouse position
- Shaders have moved to the screen texture. Now you can add any amount of shaders to be applied to the screen texture. `ShaderSupportType` enum was also added to specify if the screen texture should support no shaders, a single shaders, or any amount of shaders.
- Camera has move to the screen texture as well. A screen texture can have a single camera that is used for the `DrawGame` pass. The game mouse position will be scaled by the camera if one is used.
- There are 2 events for drawing now: `OnDrawGame`  and  `OnDrawGameUI`
- `OnDrawGame` is called before shaders are applied and the camera affects what area of the game world is drawn
- `OnDrawGameUi` is called after shaders are applied and the camera has no effect on it. This is useful for ui elements because it will always be on top.
- Clear background system that allows for a fine control of when and how the texture is cleared. In most cases clearing every frame before drawing to the texture is necessary and a custom `BackgroundColor` can be specified for that. In some cases clearing should only happen in certain intervals or not at all and to allow that a function can be set in the screen texture to control that.

## Random Number Generator
- ShapeRandom class removed. ShapeRandom was a static class that used a static RandomNumberGenerator field and wrapped every single function. Maintaining this is tedious because any change in the RandomNumberGenerator class that changes functions or function declaration results in duplicate work in the ShapeRandom class.
- RandomNumberGenerator class renamed to Rng
- Rng class now has a static Instance field that can be used like ShapeRandom

## Improvements

- ShapeVec class ExpDecay and Pow Lerp improvements.
- Pool system improvements
- ShapeId system improvements
- Additional Segment constructor implemented
- `ScreenTexture TextureFilter` property added. (GameTexture/ScreenShaderBuffer now use Bilinear filtering by default)
- Endless Space Example visual improvements.
- `WindowSize` in `WindowSettings` now defaults to 960x540.
- `SizeLerp*` functions added.
- You can now cycle through various screen shaders in the examples project
- `ColorPalette` class added. A color palette holds `PaletteColors.` `ColorSchemes` can be applied to color palettes to change the rgba colors of all contained palette colors.
- ColorScheme class overhauled.
- `PaletteColor` class `Clone()` functions added.
- New window handling system with dedicated functions for all `WindowDisplayStates` and a `RestoreWindow()` function.
- `GameWindow`  and  `Game` classes now have static `CurrentInstance`\* fields for easy static access to everything. There can only be one `Game`  and  `GameWindow` class anyway and the `GameWindow` constructor is internal, so it should be reasonably safe to use.
- `GameWindow` class `MouseOnScreen` system should work better now. This system tells you if the mouse cursor is on the screen of the window or not. Additionally, it takes care of showing/hiding the cursor when the mouse leaves the window or the window loses focus or the window is minimized.

## Fixes

- I have adjusted the line thickness of all calls to raylib functions that draw outlines (multiplied line thickness by 2) to make the line thickness look consistent across all functions that use it.
- Game multishader bug fixed
- Endless Space Collision Example targeting of player guns with short detection range fixed.
- GameWindow now calls `InitWindow()` with `WindowSettings.WindowMinSize` (if `InitWindow()` is called with 0,0 then auto iconify is disabled!)

## New

- `LineDrawingInfo` Struct implemented
- `DrawGappedOutline*` for all shapes implemented
- `DrawLinesScaled*` for all shapes  implemented
- `PolarCoordinates` struct implemented
- `ControlNodeSlider` UI element implemented
- Pixelation shader added to examples.
- `FramebufferTransparent` member added to `WindowSettings` because this flag needs to be set before `InitWindow()` as well.
- `WindowConfigFlags` struct added in `GameWindow` class. (for detecting flag changes)
- Locked Timestep physics update loop added. (Fixed physics frame rate can be set and the physics update will always run at the specified frame rate)
- `InputEventHandler` implemented. Listeners can subscribe to the handler to receive input event callbacks. The propagation of the event can be stopped. The listeners are sorted by priority. (Lower priority is handled first, more important)
- New screen shaders added to examples
- `DrawCursorGame`, `DrawCursorGameUi`, `DrawCursorUi` virtual functions added to Game class. Replaces `ICursor` system.
- Fixed Update loop added. Can be enabled by setting a `FixedFramerate` bigger than 0. The fixed update loop has a fixed delta value independent of the current frame rate and delta time of the application and will call `FixedUpdate()` to consume the delta time produced by the application. A fixed update loop can be very helpful for physics and collision because the delta time is predictable. If the fixed update loop is enabled `HandleInput()` will be called every frame before `FixedUpdate()`  and  `InterpolateFixedUpdate()` will be called at the end of the frame with the fraction of  application delta time left.
- `WindowSettings``Topmost`  and  `FullscreenAutoRestore` fields added. `FullscreenAutoRestores` automatically exits fullscreen when window loses focus and restores fullscreen when window gains focus again.
- `GameWindow` class `SetWindowTopmost(bool topmost)` function added.
- There is now a `Fullscreen(int width, int height)` and a `BorderlessFullscreen()` mode.
- EndlessSpaceExample star parallax backgrounds added using the new `ScreenTexture` custom mode. The stars are drawn once to each screen texture (there are 5 parallax layers in the example right now) and based on the current camera position a certain rectangle of each screen texture is drawn to the screen.
- AnchorPoint struct added. Is used for alignment or ui/rect anchor.

## Deprecated/ Removed

- `DrawDotted*` functions for all shapes removed (replaced by gapped outline)
- `ICursor` system removed
- `IColorPalette` interface removed (replaced by new `ColorPalette` class)
- `PrevDisplayStateInfo` struct removed.