C# Game libraryCreated by maxtingle on Tue 27th May 2014 in category C#. 830 Views | Tags: C#, GameLibrary, GameEngine, Game, Development, GameDevelopmentThis project is the largest project i've created so far and the first one to be completely documented and designed for future use. It is a GDI+ based library for creating games with many different helper classes and features put in to make the game development process as easy as possible.
I created the game library because I wanted more experience in C# and had very few ideas for software, but knew that game development is infinitely more complex than most software development, making it a great way to improve my programming skills. I went into the project with a simple idea, make the development process of games as easy as possible, I've used tools such as GameMaker before (As you've probably seen in my other projects) and I loved how easy the development process was, how easy to understand and easy to manage everything was, so I set out to make my library as easy to use as possible.
Currently, the game engine has the following features:
- Input handling helper for both mouse and keyboard (Supports multiple triggers for the same event). Based upon System.Windows.Forms.Keys to make rebinding as easy as possible.
- Collision handling with multiple checking modes (Hitbox and real hitbox) and multiple methods of choosing who to check collision with (TypeID and object ID, with object ID automatically being assigned)
- Entity class which essentially acts as a facade for most of the helper classes with a few extra helper functions such as Move which uses a Direction enum and two ints for speed.
- Double buffered drawing which will draw as fast as a single CPU core can handle. Since GDI+ is being used for drawing interpolation and other settings are also available.
- Loop class which handles the game loop for you, will call logic methods at an FPS you choose (Can skip up to 10 frames per second) and draw method as fast as possible.
- Scene class which brings all entities, timers, input handlers and other drawable objects together. A scene is what the loop class uses for drawing and logic (Loop class calls the scene draw and logic methods). Also supports scene focus lost and focus got and backgrounds.
- Debugging, logs all settings, all entity data (Regardless if it's in the base class or not), the rendered FPS and the logical FPS.
- Debug logging console which you can write to from anywhere
- Mouse handling including hiding the cursor, showing the cursor and setting a custom cursor.
- A large amount of options such as FPS, window top most, freeze game on focus lost, etc
- SpriteManager class for loading sprites from sprite sheets. Supports not-full sprite sheets (Where there are less images than the column * row would say there is), pre-loading of sprites, actual hitbox generation (The normal hitbox is the one used to pick sprites from the sprite sheet, this one checks the pixels and creates a perfect box around each individual sprite), sprite flipping (Vertical and horizontal) and more.
- Game menu helper class which handles essentially everything in a menu for you. Supports sub menus, text alignment (Left, center and right), mouse and keyboard input, triggers or no triggers on menu items, etc.
- Misc helper class for things like getting the width of a string or getting a font family buy name
- Game timer class, similar to the System.Windows.Forms.Timer class but based entirely upon the gmae ticks, a game timer instance is added to a scene and when the scene is active the game timer will tick.
Download with source