Well the title is an Homage to James Silva‘s I MAED A GAM3 W1TH Z0MB1ES!!!1

I’ve been really busy with my Dream Build Play game lately. Although being a simple game somethings always turn out to be harder that we initial think. I’ve been debating myself with some bugs on my engine, had to redo tons of code yesterday due to XBOX360 compatibilities (should have tested earlier :P). Two days ago Rita started doing the assets and it’s looking really good.

Back to the development part yesterday I panicked when she asked me if it was possible to make some some small cutscenes on each level which could include moving images, changing an animation, trigger a sound, trigger another movement after another has finished etc.

Some triggers and such would be suffice but since I like a good challenge and always loved Lua on C++ I decided to do a little research just to find that there isn’t many options for XNA, luainterface only works on Windows.

I decided to write a little parser that finds functions from a file to C# delegates and vice versa.

Here’s an example of what one of my scripts look like:


function game_start
	set_background_image  level2
	set_text name:level_indicator scene:main "Level 2"	
end

function indicates the beginning of a function. I can call it by doing:


ScriptManager.Invoke("game_start");

No binding of any kind are need till this point. Now if you read the first instruction on the script its set_background_image which is bind to a c# function, something like this:


 ScriptManager.addBind("set_background_image", SB_set_background_image);

Easy right? So now I can call my game_start function that can call other stuff on C#, I just have to hook it to a function. Any leading parameters after the instruction are passed send to it. In this case “level2” which is the image name.

Another cool stuff I’ve made and that you can see on the video below is a sleep.


function game_start
	set_background_image  level2
        sleep 2000
	set_text name:level_indicator scene:main "Level 2"	
end

In this case the function will “Sleep” for 2 seconds before resuming the next Line, and yes the rest of the game still carries on its normal way.
This may not seem much but after a few more tweaks I can make simple scripts pretty easy, not powerful as lua, not even close but it will work great for my Dream Build Play game.
Watch the video below: