Skip to content

Commit

Permalink
trying to move diagrams before json
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeselincourt committed Oct 20, 2018
1 parent 5a210bd commit 030283f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# megagameML

The name is misleading - it's not a markup language.
Code project that procedurally generates design specifications for Megagames as a JavaScript Object/JSON, then renders that object into a (intentionally vague) design document.

To run, download and open the "-grass" html.
See the output at https://mdeselincourt.github.io/megagameML/
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ <h2>Generating...</h2>
<span class="byline">The Megagame</span>
</div>
<span id="mainContent">
...
Generating...
</span>
<!--
Used before the JS could dynamically create canvases. Retained for debugging.
<div id="staticCanvasDiv">
<canvas id="staticCanvas" width="400" height="400"></canvas>
</div>
Expand Down
20 changes: 16 additions & 4 deletions megagame.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ const RESOURCE_FUNCTIONS = ["Scoring", "Investing", "Trading"];
$("#mainTitle h2").html(megagame.name);

drawCharts(megagame);

outputJSON(megagame);
}

////////////////////////////
Expand Down Expand Up @@ -652,8 +654,6 @@ const RESOURCE_FUNCTIONS = ["Scoring", "Investing", "Trading"];

description += describeEconomy(mg);

description += "<h2>MegagameML:</h2><p><pre>" + syntaxHighlight(mg) + "</pre></p>";

return description;

}
Expand Down Expand Up @@ -821,10 +821,22 @@ const RESOURCE_FUNCTIONS = ["Scoring", "Investing", "Trading"];
// end of this ideology space
}
// All ideology spaces drawn



} // end of drawCharts

// HTML-ify the JSON and display
function outputJSON(mg) {
var description = "<h2>MegagameML:</h2><p><pre>" + syntaxHighlight(mg) + "</pre></p>";

var newHeader = document.createElement('h2');
var newPara = document.createElement('p');
var newPre = document.createElement('pre');

newPre.innerHTML = syntaxHighlight(mg);

document.getElementById('mainContent').appendChild(newCanvas); // adds the canvas to #someBox

}

////////////////////
// UTILITY FUNCTIONS
Expand Down

0 comments on commit 030283f

Please sign in to comment.