|
| 1 | +# CShellEngine |
| 2 | +CShellEngine is a framework library designed to help set up the boilerplate for C-based terminal games and applications. |
| 3 | + |
| 4 | +## Features |
| 5 | +- 3D/2D grid system. |
| 6 | +- Rendering of grid system. |
| 7 | +- Keyboard input handling. |
| 8 | +- Random number generation. |
| 9 | +- Game loop handling. |
| 10 | +- Delta time for game loop system. |
| 11 | +- Datatypes such as: `Vector2i`, `Vector3i`, `Vector2f`, `Vector3f`. |
| 12 | + |
| 13 | +## Platforms |
| 14 | +``` diff |
| 15 | ++ Linux: Tested, supported. |
| 16 | +- Windows: Untested, currently unsupported. |
| 17 | +! macOS: Untested, expected to work (may require specific terminal settings/environment). |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | +Simply include the headers you need in your C program. |
| 22 | +And make sure to include all C source files in compilation. |
| 23 | + |
| 24 | +## Example |
| 25 | +``` c |
| 26 | +#include "Core.h" |
| 27 | +#include "Rendering.h" |
| 28 | +#include "Input.h" |
| 29 | + |
| 30 | +void game_loop() { |
| 31 | + printf("main method.\n"); |
| 32 | + Core___game_loop_quit_flag = true; |
| 33 | +} |
| 34 | + |
| 35 | +void render() { |
| 36 | + Rendering___render(NULL); |
| 37 | +} |
| 38 | + |
| 39 | +int main() { |
| 40 | + Vector3i grid_size_ = {3, 1, 2}; |
| 41 | + Core___initCore(&grid_size_, &game_loop, NULL); |
| 42 | + Rendering___init(NULL); |
| 43 | + |
| 44 | + Input___setInputMode(false, false); |
| 45 | + Rendering___setMapping(1, "Hello World!\n"); |
| 46 | + |
| 47 | + Core___grid[0][0][0] = 1; |
| 48 | + |
| 49 | + while (!Input___isKeyPressed('a')); // wait for 'a' key |
| 50 | + |
| 51 | + printf("\na pressed\n"); |
| 52 | + printf("%c pressed\n", Input___getKey()); // wait for and print pressed key |
| 53 | + |
| 54 | + Core___startGameLoop(&render); |
| 55 | + |
| 56 | + printf("\ndelta time: %f\nrender time: %f\n", Core___delta_time, Rendering___render_time); |
| 57 | + |
| 58 | + Rendering___cleanup(NULL); |
| 59 | + Core___cleanupCore(NULL); |
| 60 | + Input___setInputMode(true, true); |
| 61 | + |
| 62 | + return 0; |
| 63 | +} |
| 64 | +``` |
0 commit comments