Snake: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor tidy)
Line 5,120: Line 5,120:
{{libheader|Wren-dynamic}}
{{libheader|Wren-dynamic}}
An embedded program so we can ask the C host to call ncurses and another library function for us.
An embedded program so we can ask the C host to call ncurses and another library function for us.
<syntaxhighlight lang="ecmascript">/* snake.wren */
<syntaxhighlight lang="wren">/* Snake.wren */


import "random" for Random
import "random" for Random
Line 5,258: Line 5,258:
<br>
<br>
Now embed this script in the following C program, compile and run it.
Now embed this script in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc snake.c -o snake -lncurses -lwren -lm */
<syntaxhighlight lang="c">/* gcc Snake.c -o Snake -lncurses -lwren -lm */


#include <stdio.h>
#include <stdio.h>
Line 5,404: Line 5,404:
WrenVM* vm = wrenNewVM(&config);
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* module = "main";
const char* fileName = "snake.wren";
const char* fileName = "Snake.wren";
char *script = readFile(fileName);
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
WrenInterpretResult result = wrenInterpret(vm, module, script);