Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Shaw committed Sep 22, 2015
1 parent 885e6e4 commit 9349d9a
Show file tree
Hide file tree
Showing 13 changed files with 62,478 additions and 62,267 deletions.
Binary file added backgroundxcf.xcf
Binary file not shown.
99 changes: 99 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import shutil
import glob
import os
import json
import code
import sass
from subprocess import call

def generate_entrypoint_file(mode):
with open('node_modules/ensemblejs/default.entrypoint.js', 'r') as source:
with open(''.join(['build/', mode, '.js']), 'wb') as dest:
dest.write(source.read())
dest.write("\nentryPoint.set('GameMode', '" + mode + ");\nentryPoint.run();");

SOURCE = { 'js': glob.glob('game/js/*.js'),
'scss': glob.glob('game/scss/*.scss') }


DIST = { 'root': 'dist',
'js': glob.glob('dist/js/*.js'),
'css': glob.glob('dist/css/*.css'),
'css_map': glob.glob('dist/css/*.css.map') }

# clean
print 'clean'

for f in ["game/js/gen", "game/css", "dist", "build"]:
shutil.rmtree(f, ignore_errors=True)

print 'npm install'
ret = call('npm install', shell=True)
if ret != 0:
exit(ret)

print 'preflight'
# preflight
for f in ["dist/js", "dist/css", "game/js/gen", "game/css", "build"]:
os.makedirs(f)

# generate entry-points
mode_filename = 'game/js/modes.json'
if os.path.isfile(mode_filename):
with open(mode_filename, 'r') as mode_file:
modes = json.load(mode_file)
for mode in modes:
generate_entrypoint_file(mode)
#code.interact(local=dict(globals(), **locals()))

# withjson.load
# arr = []
# json.
# arr = JSON.parse(File.read(modes_file)) if File.exists? modes_file
# arr << 'game' if arr.empty?

# arr.each do | mode |
# generate_entrypoint_file mode
# end





print 'browserify'
# browserify
entry_points = ' '.join(SOURCE['js'])
targets = ' -o '.join(SOURCE['js']).replace('game', DIST['root'])

ret = call('browserify -d ' + entry_points + ' -p [ factor-bundle -o ' + targets + ' ] -o ' + DIST['root'] + '/js/common.js', shell=True)

if ret != 0:
exit(ret)

print 'sass'
# sass
for f in SOURCE['scss']:
css_f = f.replace('game/scss/', '').replace('.scss', '')
ret = call('node-sass ' + f + ' ' + DIST['root'] + '/css/' + css_f + '.css', shell=True)
if ret != 0:
exit(ret)

print 'minify'
# minify
for f in DIST['css']:
min_f = f.replace('.css', '.min.css')
ret = call('cssnano < ' + f + ' > ' + min_f, shell=True)
if ret != 0:
exit(ret)
print f
os.remove(f)

print 'uglify'
# uglify
for f in DIST['js']:
min_name = f.replace(".js", ".min.js")
ret = call('uglifyjs --compress --mangle -- ' + f + ' > ' + min_name, shell=True)
if ret != 0:
exit(ret)
print f
os.remove(f)
11 changes: 11 additions & 0 deletions build/easy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var entryPoint = require('ensemblejs/client');
entryPoint.loadWindow(require('window'));
entryPoint.loadDefaults();
entryPoint.loadClientFolder(require('../game/js/logic/**/*.js', {mode: 'hash'} ));
entryPoint.loadClientFolder(require('../game/js/maps/**/*.js', {mode: 'hash'} ));
entryPoint.loadClientFolder(require('../game/js/events/**/*.js', {mode: 'hash' }));
entryPoint.loadClientFolder(require('../game/js/views/**/*.js', {mode: 'hash' }));
entryPoint.set('GameMode', 'easy);
entryPoint.run();
11 changes: 11 additions & 0 deletions build/hard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var entryPoint = require('ensemblejs/client');
entryPoint.loadWindow(require('window'));
entryPoint.loadDefaults();
entryPoint.loadClientFolder(require('../game/js/logic/**/*.js', {mode: 'hash'} ));
entryPoint.loadClientFolder(require('../game/js/maps/**/*.js', {mode: 'hash'} ));
entryPoint.loadClientFolder(require('../game/js/events/**/*.js', {mode: 'hash' }));
entryPoint.loadClientFolder(require('../game/js/views/**/*.js', {mode: 'hash' }));
entryPoint.set('GameMode', 'hard);
entryPoint.run();
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"logging": {
"logLevel": "error"
},
"client": {
"aspectRatio": 1
}
}
1 change: 1 addition & 0 deletions dist/js/common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9349d9a

Please sign in to comment.