Skip to content

Instantly share code, notes, and snippets.

@samanthamjohn
Last active February 28, 2017 13:54
Show Gist options
  • Save samanthamjohn/cfcdbec936bd5473a080b8861c3648bc to your computer and use it in GitHub Desktop.
Save samanthamjohn/cfcdbec936bd5473a080b8861c3648bc to your computer and use it in GitHub Desktop.
Hopscotch Project structure

How to parse

  1. Add all the globalVariables to the scope.
  2. Add all the instanceVariables to the object prototype.
  3. Add all the objects to the scope.
  4. Add all the abilities to the scope.
  5. Add all the scenes to the scope.

How to export a project.

  1. Find all global variables and add them to globalVariables
  2. Find all object property names and add them to instanceVariables
  3. Find all objects and add their starting position, name and type to objects
  4. Find all the abilities and add them to abilities.
  5. Find all the scenes and add them Scenes.

Exporting a scene

  • For each object in the scene add a key with object name, value: (array) rules list
  • for each rule in the object rule list, add an object
  • rule_id: rule.id
  • trigger: export the rule parameter
  • blocks: blocks inside the rule
{
"globalVariables" : ["foo", "bar", "baz"],
"instanceVariables" : ["a", "b", "c"],
"objects": ["objects"],
"abilities" : {
"name" : ["methods"],
"name" : ["methods"],
},
"scenes" : ["scenes"]
}
{
"name": "daisy",
"x" : 100,
"y" : 10,
"type" : "dino",
}
{
"funky" : ["method1", "method2", "method3"],
"valgo" : ["method5", "method3", "funky"],
}
{
"id" : "rule1",
"trigger" : {
"event" : "start game"
},
"code" : ["methods"]
},
{
"id" : "rule2",
"trigger" : {
"event" : "on tap",
"parameters" : ["param1"]
},
"code" : ["methods"]
}
{
"name" : "move",
"parameters" : []
}
{
"object" : "Daisy",
"rules" : ["rules"]
}
{
"name" : "quux",
"type" : "number",
"value" : {
"name" : "qux",
"type" : "add",
"parameters" : ["params"]
}
}
{
"name" : "bar",
"type" : "color",
"value" : {
"type" : "self",
"name" : "a"
},
}
{
"name" : "scene 1",
"objects" : ["object_rules"]
}
{
"name" : "foo",
"value" : 100,
"type" : "number"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment