Skip to content

Instantly share code, notes, and snippets.

@kchodorow
Created December 24, 2015 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kchodorow/0468be7845fec4cea83e to your computer and use it in GitHub Desktop.
Save kchodorow/0468be7845fec4cea83e to your computer and use it in GitHub Desktop.
Setup a directory for making a game with Phaser.io, Closure, and Git
#!/bin/bash
set -e
js/closure-library/closure/bin/build/depswriter.py --root_with_prefix='. ../../../..' > deps.js
cat deps.js
#!/bin/bash
GAME_NAME=$(basename $PWD)
# Make js directory
mkdir js
# Add phaser
cp ~/gitroot/phaser/build/phaser.js js
# Add closure library
ln -s ~/gitroot/closure-library js/closure-library
# Set up a Globals file.
cat > js/globals.js <<EOF
goog.provide('$GAME_NAME.Globals.game');
EOF
# Set up the 'runner' script for Phaser.
cat > js/${GAME_NAME}.js <<EOF
goog.require('$GAME_NAME.Globals.game');
var game = new Phaser.Game(800, 600, Phaser.CANVAS);
var preload = function() {
$GAME_NAME.Globals.game = game;
};
EOF
# Set up index.html.
cat > index.html <<EOF
<html>
<head>
<title>${GAME_NAME}</title>
</head>
<body>
<script src="/js/phaser.js"></script>
<script src="/js/closure-library/closure/goog/base.js"></script>
<script src="/deps.js"></script>
<script src="/js/${GAME_NAME}.js"></script>
</body>
</html>
EOF
# Generate initial deps file.
deps.sh > /dev/null
# VERSION CONTROL
# Set up .gitignore
cat > .gitignore <<EOF
js/phaser.js
js/closure-library
EOF
# Stage everything
git init
git add index.html deps.js js .gitignore
echo "Ready to go! Start up your Python server with:"
echo "python -m SimpleHTTPServer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment