UPDATE
Lua Scripting Engine Demo
So far only 1 demo, This demo is the same as the default project for DarkGDK 2d game Wizard. The only difference is it is written in lua. The lua file is then executed by my executable. Heres the code:
main.cpp
#include "DarkGDK.h"
#include "LUADarkGDK.h"
void DarkGDK ( void )
{
dbSetWindowTitle("LUA-DarkGDK demo");
initialize_script();
execute_script( "script.lua" );
while ( LoopGDK ( ) )
{
dbSync ( );
}
close_script();
return;
}
script.lua
dbSyncOn()
dbSyncRate(60)
dbLoadImage("backdrop.bmp",1)
dbSprite(1,0,0,1)
dbSetImageColorKey(255,0,255)
i=2
while(i<=30)
do
dbCreateAnimatedSprite(i,"sprite.bmp",4,4,i)
dbSprite(i,dbRnd(640),-dbRnd(1500),i)
i=i+1
end
while(LoopGDK())
do
i=2
repeat
dbMoveSprite(i,-2)
dbPlaySprite(i,1,16,60)
if(dbSpriteY(i)>500) then dbSprite(i,dbRnd(640),-dbRnd(1500),i) end
i=i+1
until (i>=30)
dbText(0,0,"running script....")
dbText(0,20,dbStr(dbScreenFPS()))
dbSync()
end
As you can see, the name of the lua functions wrapping DarkGDK functions is the same as the ones for C++. Here's a screenshot. And download attached. You can change the lua file if you want. By default, the script won run if you have syntax error in code. If you have a parameter argument error, you will be prompted by GDK and show the erring line. Screenshot.
And Download attached for the executable,script and media.
When a person has nothing but a dream, can he dare to dream.