2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-03 11:09:40 -04:00

Update README.md

This commit is contained in:
ChrisDill 2019-03-03 15:47:05 +00:00 committed by GitHub
parent a01efa4a09
commit ec9cace42e

View File

@ -8,53 +8,41 @@ C# bindings for raylib 2.0, a simple and easy-to-use library to learn videogames
So far, I have only tested on Windows. Tips on making things work smoothly on all platforms is appreciated.
1. Add the [nuget package](https://www.nuget.org/packages/Raylib-cs/)
2. Start coding!
```csharp
using Raylib;
using static Raylib.Raylib;
using rl = Raylib.Raylib;
static class Program
{
public static void Main()
{
InitWindow(640, 480, "Hello World");
rl.InitWindow(640, 480, "Hello World");
while (!WindowShouldClose())
while (!rl.WindowShouldClose())
{
BeginDraw();
rl.BeginDraw();
ClearBackground(Color.WHITE);
DrawText("Hello, world!", 12, 12, 20, Color.BLACK);
rl.ClearBackground(Color.WHITE);
rl.DrawText("Hello, world!", 12, 12, 20, Color.BLACK);
EndDrawing();
rl.EndDrawing();
}
CloseWindow();
rl.CloseWindow();
}
}
```
# Tech notes
The bindings are close to the original with a few changes and extensions.
- Enums are passed in as type instead of int to avoid explicit casting to a int every time.
- Added constructors for some of the types.
- Enums are passed as `int` to prevent the need for explicit casts.
- Color defines stored inside `Color` so `RAYWHITE` changes to `Color.RAYWHITE`.
- Uses `string.Format` in place of `TextFormat`.
## Custom build
1. Add [raygui](https://github.com/raysan5/raygui)
2. Add a file with the following
```c
#include "raylib.h"
#include "easings.h"
#define PHYSAC_NO_THREADS
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
```
# Extras
- Structs have constructors.
- Operator overloading for math types.
## Contributing
If you have any ideas, feel free to open an issue and tell me what you think.