Boids/Wren: Difference between revisions
m
→Code: Capitalize Wren file name.
m (→Code: Fixed syntax highlighting.) |
m (→Code: Capitalize Wren file name.) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 8:
<br>
As it's not currently possible for Wren-cli to access OpenGL directly, we embed a Wren script in a C application to complete this task. See the [[OpenGL#Wren]] task for some of the issues involved here.
<syntaxhighlight lang="
import "random" for Random
Line 556:
Boids[i].speed = (0.98 + 0.04 * Rand.float()) * MOVE_SPEED
}
InitGL.call()</
<br>
We now embed this Wren script in the following C program, compile and run it.
<
#include <stdlib.h>
#include <string.h>
Line 960:
vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
|