Browse Source

Added a simple example

Jan Hönig 5 years ago
parent
commit
e3300ac44b
2 changed files with 36 additions and 0 deletions
  1. 13 0
      example/dub.json
  2. 23 0
      example/source/app.d

+ 13 - 0
example/dub.json

@@ -0,0 +1,13 @@
+{
+	"authors": [
+		"Unknown"
+	],
+	"copyright": "Copyright © 2020, Unknown",
+	"dependencies": {
+		"raylib-d": "~>3.0.0"
+	},
+  "libs": [ "raylib" ],
+	"description": "A minimal D application.",
+	"license": "zlib License",
+	"name": "example"
+}

+ 23 - 0
example/source/app.d

@@ -0,0 +1,23 @@
+import std.stdio;
+
+import raylib;
+
+void main()
+{
+	writeln("Starting a raylib example.");
+
+  SetTargetFPS(60);
+  InitWindow(800, 640, "Hello, World!");
+  scope(exit) CloseWindow(); // see https://dlang.org/spec/statement.html#scope-guard-statement
+
+  while (!WindowShouldClose())
+  {
+    BeginDrawing();
+    scope(exit) EndDrawing();
+
+    ClearBackground(RAYWHITE);
+    DrawText("Hello, World!", 330, 300, 28, BLACK);
+  }
+
+	writeln("Ending a raylib example.");
+}