Commit 2e8150a2 authored by Matthew Odle's avatar Matthew Odle

refactor script loading

parent b8b50f66
var canvasPath = '../canvas-libs/app/scripts/';
// var canvasPath = 'https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/';
var mainPath = 'app/scripts/';
var canvasFiles = [
'supporting.js',
'component.js',
'controls/gamepad.js',
'controls/keyboard.js',
'controls.js',
'dom.js',
'gameBase.js',
'game-area.js',
'hud.js',
'leaderboard.js',
'mainBase.js',
'menus/initials.js',
'menus/main-menu.js',
'menus.js',
'playerBase.js',
'sound.js',
'templates.js',
];
var mainFiles = [
'collisions.js',
'component.js',
'components/centipedes.js',
'components/interval-creatures.js',
'components/lasers.js',
'components/metrics.js',
'components/mushrooms.js',
'components/players.js',
'components/texts.js',
'components/spiders.js',
'game.js',
'knobs-and-levers.js',
'main.js',
'properties/menus-props.js',
'sound.js',
];
var canvasInitFiles = [
'init/init.js',
];
var mainInitFiles = [
'init/init.js',
];
var targetDomObject = 'head';
function loadScript (path, file) {
var script = document.createElement("script");
script.src = path + file;
document[targetDomObject].appendChild(script);
console.log(script.src, 'added to', targetDomObject);
};
canvasFiles.forEach(file => loadScript(canvasPath, file));
mainFiles.forEach(file => loadScript(mainPath, file));
canvasInitFiles.forEach(file => loadScript(canvasPath, file));
mainInitFiles.forEach(file => loadScript(mainPath, file));
console.log(document[targetDomObject]);
......@@ -3,56 +3,11 @@
<head>
<link rel="stylesheet" type="text/css" media="screen" href="app/static/css/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script src="app/scripts/load.js"></script>
</head>
<body onload="game.start()">
<div id="canvas-wrapper"></div>
</body>
<footer>
<!-- use rel paths for testing; convert to canvas-libs external source before merging to master -->
<script src="../canvas-libs/app/scripts/supporting.js"></script>
<script src="../canvas-libs/app/scripts/component.js"></script>
<script src="../canvas-libs/app/scripts/controls/gamepad.js"></script>
<script src="../canvas-libs/app/scripts/controls/keyboard.js"></script>
<script src="../canvas-libs/app/scripts/controls.js"></script>
<script src="../canvas-libs/app/scripts/dom.js"></script>
<script src="../canvas-libs/app/scripts/gameBase.js"></script>
<script src="../canvas-libs/app/scripts/game-area.js"></script>
<script src="../canvas-libs/app/scripts/hud.js"></script>
<script src="../canvas-libs/app/scripts/leaderboard.js"></script>
<script src="../canvas-libs/app/scripts/mainBase.js"></script>
<script src="../canvas-libs/app/scripts/menus/initials.js"></script>
<script src="../canvas-libs/app/scripts/menus/main-menu.js"></script>
<script src="../canvas-libs/app/scripts/menus.js"></script>
<script src="../canvas-libs/app/scripts/playerBase.js"></script>
<script src="../canvas-libs/app/scripts/sound.js"></script>
<script src="../canvas-libs/app/scripts/templates.js"></script>
<!-- <script type="text/javascript" src="https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/controls/gamepad.js"></script>
<script type="text/javascript" src="https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/controls/keyboard.js"></script>
<script type="text/javascript" src="https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/controls.js"></script>
<script type="text/javascript" src="https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/sound.js"></script>
<script type="text/javascript" src="https://glcdn.githack.com/taciturn-pachyderm/canvas-libs/raw/v2.2.0/app/scripts/supporting.js"></script> -->
<script src="app/scripts/collisions.js"></script>
<script src="app/scripts/component.js"></script>
<script src="app/scripts/components/centipedes.js"></script>
<script src="app/scripts/components/interval-creatures.js"></script>
<script src="app/scripts/components/lasers.js"></script>
<script src="app/scripts/components/metrics.js"></script>
<script src="app/scripts/components/mushrooms.js"></script>
<script src="app/scripts/components/players.js"></script>
<script src="app/scripts/components/texts.js"></script>
<script src="app/scripts/components/spiders.js"></script>
<script src="app/scripts/game.js"></script>
<script src="app/scripts/knobs-and-levers.js"></script>
<script src="app/scripts/main.js"></script>
<script src="app/scripts/properties/menus-props.js"></script>
<script src="app/scripts/sound.js"></script>
<!-- this needs to be loaded last or dependency object will not be available -->
<!-- for karma tests, it needs to be a separate directory -->
<script src="../canvas-libs/app/scripts/init/init.js"></script>
<script src="app/scripts/init/init.js"></script>
</footer>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment