-
Notifications
You must be signed in to change notification settings - Fork 0
/
BBQLib.cs
116 lines (96 loc) · 2.74 KB
/
BBQLib.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using BBQLib.Backends;
using System.Collections.Generic;
using System;
using System.IO;
using System.Numerics;
namespace BBQLib
{
public static class BBQLib
{
internal static WindowImplementation window;
internal static SoundPlayer soundPlayer;
public static string rootDirectory = "";
public static void Init(WindowConfig config)
{
window = new SFMLWindow(config);
soundPlayer = new SFMLSoundPlayer();
}
public static float DeltaTime
{
get
{
return window.DeltaTime;
}
}
public static void PlaySound(string sound)
{
soundPlayer.PlaySound(sound);
}
public static void LoadSounds(string directory)
{
soundPlayer.soundDir = rootDirectory + directory;
foreach(var filename in Directory.GetFiles(rootDirectory + directory))
{
soundPlayer.LoadSound(filename);
}
}
public static Sprite CreateSprite(byte[] palette, byte[] buffer, uint width, uint height, string name)
{
return PalettedSprite.CreatePalettedSprite(palette, buffer, width, height, false, name);
}
public static Sprite CreateSprite(byte[] buffer, uint width, uint height, string name)
{
return window.CreateSprite(buffer, width, height, name);
}
public static Sprite RegisterSprite(string filename)
{
return window.CreateSprite(filename);
}
public static void LoadFonts(string filename)
{
window.LoadFonts(filename);
}
public static void Clear()
{
window.Clear();
}
public static void Dispose()
{
}
public static Vector2 ScreenToWorld(Vector2 A)
{
return A + Camera - window.Size / 2;
}
public static Vector2 Camera = new Vector2();
public static Vector2 Size
{
get
{
return window.Size;
}
}
public static void Draw(Sprite sprite)
{
window.Draw(sprite);
}
public static void Line(Vector2 A, Vector2 B, Color color)
{
window.DrawLine(A, B, 4, color);
}
public static void Draw(string font, string text, Vector2 position)
{
window.Draw(font, text, position);
}
public static bool IsOpen
{
get
{
return window.IsOpen;
}
}
public static void Display()
{
window.Present();
}
}
}