For my BSc final project I created a game creator tool which consisted of two parts:

1. The editor which allowed for the creation and naming of game objects and laying out code blocks.

2. The interpreter which ran the lua code and translated it into XNA commands.


The code block editor was interesting to write, it imported xml files which contained the UI elements that needed filling out and the code that it created:

<?xml version ="1.0" encoding ="utf-8"?>

<data>

<CodeNodeName>MoveEntity</CodeNodeName>

<ToolBoxPosition>2,0</ToolBoxPosition>

<CoreString>MoveEntity([Variable1],CreateVector([Variable2],[Variable3]));</CoreString>

<NodeColour R="0" G="255" B="0"></NodeColour>


<GUIElement id="0">Label</GUIElement>

<GUIElementPos id="0">10,610</GUIElementPos>

<GUIElementDimensions id="0">100,100</GUIElementDimensions>

<GUIElementValue id="0">Moves an entity a set distance</GUIElementValue>


<GUIElement id="1">EntityDropDown</GUIElement>

<GUIElementPos id="1">10,640</GUIElementPos>

<GUIElementDimensions id="1">100,20</GUIElementDimensions>

<GUIElementValue id="1"></GUIElementValue>

<GUIElement_LinkedVariable id="1">0</GUIElement_LinkedVariable>


<GUIElement id="2">TextBox</GUIElement>

<GUIElementPos id="2">115,640</GUIElementPos>

<GUIElementDimensions id="2">100,20</GUIElementDimensions>

<GUIElementValue id="2">X Distance</GUIElementValue>

<GUIElement_LinkedVariable id="2">1</GUIElement_LinkedVariable>

<GUIElement id="3">TextBox</GUIElement>

<GUIElementPos id="3">115,680</GUIElementPos>

<GUIElementDimensions id="3">100,20</GUIElementDimensions>

<GUIElementValue id="3">Y Distance</GUIElementValue>

<GUIElement_LinkedVariable id="3">2</GUIElement_LinkedVariable>


</data>

This data driven design allowed for an expanding toolbox of code nodes which could be added without recompiling.

You would select a node on the right to place and then put it on a slot on the panel, then you could link to create structure.

While this was worked, ease of use was an issue. Below is an example of the output from the editor:

ballx = 0;

bally = 0;

player1score = 0;

player2score = 0;

score = 0;


function Spawn()

ballx = 2;

bally = 0;

score = 1;

LoadTexture("Field.bmp",0);

LoadTexture("Bat.bmp",1);

LoadTexture("ball.bmp",2);

CreateEntity(0,CreateVector(0,0),0,0);

CreateEntity(1,CreateVector(3,255),1,1);

CreateEntity(2,CreateVector(770,254),1,1);

CreateEntity(3,CreateVector(383,280),2,2);

end



function Input(button)

if button == 0 then

if GetEntityLocation(1,false) > 0 then

MoveEntity(1,CreateVector(0,-3));

end

end

if button == 2 then

if GetEntityLocation(1,false) < 550 then

MoveEntity(1,CreateVector(0,3));

end

end

if button == 3 then

if GetEntityLocation(2,false) < 550 then

MoveEntity(2,CreateVector(0,3));

end

end

if button == 1 then

if GetEntityLocation(2,false) > 0 then

MoveEntity(2,CreateVector(0,-3));

end

end

end


function Think(id)

MoveEntity(3,CreateVector(ballx,bally));

ClearScreenText();

DrawText(CreateVector(350,10),player1score);

DrawText(CreateVector(450,10),player2score);

if GetEntityLocation(3,true) < 0 then

player2score = player2score + score;

PositionEntity(3,CreateVector(387,288));

end

if GetEntityLocation(3,true) > 780 then

player1score = player1score + score;

PositionEntity(3,CreateVector(387,288));

end

if GetEntityLocation(3,false) < 0 then

bally = -bally;

end

if GetEntityLocation(3,false) > 600 then

bally = -bally;

end

end


function Collision(id1,id2)

if id1 == 3 then if id2 == 1 then

ballx = 2;

bally = math.random(-1,1)  ;

end end

if id1 == 2 then if id2 == 3 then

ballx = -2;

bally = math.random(-1,1)  ;

end end

end


function Timer(id)

end

 
Make a Free Website with Yola.