-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhellosfml.nt
53 lines (44 loc) · 1.22 KB
/
hellosfml.nt
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
module hellosfml;
import std.lib.(csfml, opengl);
void main() using mode SFML {
auto mode = VideoMode:(800, 600, 32);
auto app = RenderWindow create(mode, "SFML window", 2 | 4, null);
if (!app) raise new Error "could not create window";
onExit app.destroy;
auto texture = Texture createFromFile ("indianya.png", null);
if (!texture) raise new Error "could not load image";
onExit texture.destroy;
auto sprite = Sprite create;
sprite.setTexture (texture, true);
onExit sprite.destroy;
writeln "$(string-of type-of sprite)";
auto font = Font createFromFile ("Vera.ttf");
if (!font) raise new Error "could not open font";
onExit font.destroy;
auto text = Text create;
onExit text.destroy;
using text {
setString "Hello SFML";
setFont font;
setCharacterSize 50;
}
/*
auto music = Music createFromFile "Tristram Theme.ogg";
if (!music) raise new Error "could not open music";
onExit music.destroy;
music.play;
*/
using app {
while (isOpen()) {
while (pollEvent &sfEvent ev) {
if (ev.type == EvtClosed) {
app.close();
}
}
clear Black;
drawSprite (sprite, null);
drawText (text, null);
display;
}
}
}