Skip to content

Commit cf8da14

Browse files
committed
adding examples
1 parent d70fd33 commit cf8da14

File tree

5 files changed

+88
-4
lines changed

5 files changed

+88
-4
lines changed

Examples/Save System.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
the built in save system is (should be) very trust worthy
2+
3+
```C#
4+
using static GameBox; // do this so you dont need to do GameBox.Gb all the time
5+
6+
new GameBox(new Program(), new Vector2(window width, window height, "title"))
7+
8+
public class Program : GameLoop
9+
{
10+
public override void Init()
11+
{
12+
Gb.InitSaveSystem("developer name", "app name");
13+
14+
// for every object you want to save
15+
// its best to nest save objects to not create ALOT of files
16+
Gb.RegisterSaveItem(obj, "file name");
17+
18+
// to load:
19+
Gb.LoadItems();
20+
21+
// to save:
22+
Gb.SaveItem();
23+
}
24+
25+
public override void UpdateLoop()
26+
{
27+
}
28+
29+
public override void RenderLoop()
30+
{
31+
}
32+
}
33+
```
34+
35+
adding encryption is very easy to ad
36+
you should put this before the init of gamebox if you want to set
37+
the encryption
38+
39+
```C#
40+
ISave.Cypher = (s => /*this will be encryption, it will give you a string and it wants the encrypted string back*/,
41+
s => /*this will the the decryption, it will give the encrypted string and it wants the decrypted string*/);
42+
```
43+
44+
the encryption will do a check to see if the encryption is valid or not

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ paths:
1414
- RayWrapperTester (testing program)
1515
- RayWrapperTesterCollision (collision testing program)
1616

17-
some notable features
17+
## some notable features
18+
1819
---
19-
- in game console (can add custom commands)
20+
- in game console (can add custom commands, use ` to access console)
2021
- a built in save system using Newtonsoft.Json
2122
- bad code
2223
- NumberClass is included (A big number lib)
@@ -26,7 +27,8 @@ some notable features
2627
- a not as bad animation system
2728
- internal logger and crash log system
2829

29-
small example
30+
## raw template example
31+
3032
---
3133

3234
```C#

RayWrapper/GameBox.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using System.Numerics;
7-
using System.Text;
87
using System.Threading.Tasks;
98
using Raylib_cs;
109
using RayWrapper.Animation;

RayWrapper/RayWrapper.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<PackageReference Include="Raylib-cs" Version="3.7.0" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<Folder Include="Examples" />
17+
</ItemGroup>
18+
1519
</Project>

RayWrapper/Vars/Flags.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Incremental_Unlimited_PC.Data.Vars
6+
{
7+
public class Flags<T>
8+
{
9+
public Dictionary<string, T> flags = new();
10+
11+
public string StringToHex(string text) => string.Join("", text.Select(c => ((int)c).ToString("X2")));
12+
13+
public T GetFlag(string hex, T def = default)
14+
{
15+
if (flags.ContainsKey(hex)) return flags[hex];
16+
return flags[hex] = def;
17+
}
18+
19+
public void SetFlag(string hex, T t) => flags[hex] = t;
20+
21+
public T this[Enum e]
22+
{
23+
get => GetFlag(StringToHex($"{e}"));
24+
set => SetFlag(StringToHex($"{e}"), value);
25+
}
26+
27+
public T this[params Enum[] ee]
28+
{
29+
set
30+
{
31+
foreach (var e in ee) SetFlag(StringToHex($"{e}"), value);
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)