partial loader script
This commit is contained in:
parent
8b49d564ab
commit
8235d4f532
|
@ -159,6 +159,7 @@
|
|||
<script>scripts\blocks\getConnectionsForCluster.gml</script>
|
||||
<script>scripts\blocks\layoutCluster.gml</script>
|
||||
</scripts>
|
||||
<script>scripts\loadLevel.gml</script>
|
||||
</scripts>
|
||||
<objects name="objects">
|
||||
<objects name="generic">
|
||||
|
@ -220,6 +221,7 @@
|
|||
</objects>
|
||||
<object>objects\Debug</object>
|
||||
<object>objects\TypeParser</object>
|
||||
<object>objects\LevelLoader</object>
|
||||
</objects>
|
||||
<rooms name="rooms">
|
||||
<room>rooms\roomInit</room>
|
||||
|
@ -235,4 +237,4 @@
|
|||
<TutorialName />
|
||||
<TutorialPage>0</TutorialPage>
|
||||
</TutorialState>
|
||||
</assets>
|
||||
</assets>
|
||||
|
|
|
@ -133,6 +133,30 @@ ds_map_destroy(objectNames);
|
|||
</arguments>
|
||||
</action>
|
||||
</event>
|
||||
<event eventtype="7" enumb="4">
|
||||
<action>
|
||||
<libid>1</libid>
|
||||
<id>603</id>
|
||||
<kind>7</kind>
|
||||
<userelative>0</userelative>
|
||||
<isquestion>0</isquestion>
|
||||
<useapplyto>-1</useapplyto>
|
||||
<exetype>2</exetype>
|
||||
<functionname></functionname>
|
||||
<codestring></codestring>
|
||||
<whoName>self</whoName>
|
||||
<relative>0</relative>
|
||||
<isnot>0</isnot>
|
||||
<arguments>
|
||||
<argument>
|
||||
<kind>1</kind>
|
||||
<string>if room == roomInit
|
||||
room_goto(room0)
|
||||
</string>
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</event>
|
||||
<event eventtype="8" enumb="64">
|
||||
<action>
|
||||
<libid>1</libid>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
|
||||
<object>
|
||||
<spriteName><undefined></spriteName>
|
||||
<solid>0</solid>
|
||||
<visible>-1</visible>
|
||||
<depth>0</depth>
|
||||
<persistent>0</persistent>
|
||||
<parentName><undefined></parentName>
|
||||
<maskName><undefined></maskName>
|
||||
<events/>
|
||||
<PhysicsObject>0</PhysicsObject>
|
||||
<PhysicsObjectSensor>0</PhysicsObjectSensor>
|
||||
<PhysicsObjectShape>0</PhysicsObjectShape>
|
||||
<PhysicsObjectDensity>0.5</PhysicsObjectDensity>
|
||||
<PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
|
||||
<PhysicsObjectGroup>0</PhysicsObjectGroup>
|
||||
<PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
|
||||
<PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
|
||||
<PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
|
||||
<PhysicsObjectAwake>-1</PhysicsObjectAwake>
|
||||
<PhysicsObjectKinematic>0</PhysicsObjectKinematic>
|
||||
<PhysicsShapePoints/>
|
||||
</object>
|
|
@ -0,0 +1,51 @@
|
|||
///loadLevel(json, typeMap, root)
|
||||
/**
|
||||
* loadLevel :: JSON -> ()
|
||||
*
|
||||
* Fills a level room with a level description from a JSON string.
|
||||
*
|
||||
* @param json the json level description
|
||||
*/
|
||||
|
||||
var json = argument0;
|
||||
var typeMap = argument1;
|
||||
var root = argument2;
|
||||
|
||||
assert(is_string(json), "No JSON string provided.");
|
||||
assert(ds_exists(typeMap, ds_type_map), "Invalid type map provided.");
|
||||
assertInstanceof(root, TypeConLink);
|
||||
|
||||
var map = json_decode(json);
|
||||
|
||||
assert(
|
||||
ds_exists(map, ds_type_map) &&
|
||||
ds_exists(map[?"blocks"], ds_type_list) &&
|
||||
ds_exists(map[?"goal"], ds_type_list) &&
|
||||
ds_exists(map[?"parameters"], ds_type_list) &&
|
||||
ds_exists(map[?"start"], ds_type_list) &&
|
||||
ds_exists(map[?"traits"], ds_type_list),
|
||||
"Invalid level description."
|
||||
);
|
||||
|
||||
var paramMap = ds_map_create();
|
||||
var params = map[?"parameters"];
|
||||
for (var i = 0; i < ds_list_size(params); i++) {
|
||||
var param = params[|i];
|
||||
var traits = param[?"traits"];
|
||||
|
||||
var inst;
|
||||
if (param[?"free"])
|
||||
inst = new(FreeType);
|
||||
else
|
||||
inst = new(ConcreteType);
|
||||
|
||||
inst.order = param[?"order"];
|
||||
|
||||
for (var j = 0; j < ds_list_size(traits); j++)
|
||||
|
||||
|
||||
paramMap[?param[?"name"]] = inst;
|
||||
}
|
||||
|
||||
ds_map_destroy(map);
|
||||
|
Loading…
Reference in New Issue