Skip to content

Commit

Permalink
overhaul EVERYTHING to use the Phaser yeoman generator
Browse files Browse the repository at this point in the history
  • Loading branch information
steverichey committed Apr 26, 2014
1 parent 58059ba commit bb7f528
Show file tree
Hide file tree
Showing 882 changed files with 948,023 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
21 changes: 21 additions & 0 deletions .jshintrc
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
156 changes: 94 additions & 62 deletions GruntFile.js
@@ -1,65 +1,97 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
// Generated on 2014-03-28 using generator-phaser-official 0.0.8-rc-2
'use strict';
var config = require('./config.json');
var _ = require('underscore');
_.str = require('underscore.string');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
port: 8080,
base: './deploy'
}
}
},
concat: {
dist: {
src: [ "src/lib/phaser.js",
"src/game/*.js"
],
//dest: 'src/bin/<%= pkg.name %>.js'
dest: 'deploy/js/LudumDare29.js'
}
},
watch: {
files: 'src/**/*.js',
tasks: ['concat']
},
open: {
dev: {
path: 'http://localhost:8080/index.html'
}
},
uglify: {
options: {
compress: {
drop_console: true
}
},
my_target: {
files: {
'deploy/js/<%= pkg.name %>.min.js' : ['src/bin/<%= pkg.name %>.js']
}
}
},
copy: {
main: {
files: [
{expand: true, src: ['assets/*'], dest: 'deploy/'},
// TODO THIS IS THE RELEASE VERSION
//{expand: true, flatten: true, src: ['src/index.html'], dest: 'deploy/'}
{expand: true, flatten: true, src: ['src/dev/index.html'], dest: 'deploy/'}
]
}
}
});
// Mix in non-conflict functions to Underscore namespace if you want
_.mixin(_.str.exports());

grunt.registerTask('default', ['concat', 'uglify', 'copy']);
grunt.registerTask('embiggened', ['concat', 'copy']);
grunt.registerTask('open-watch', ['concat', 'connect', 'open', 'watch']);
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.initConfig({
watch: {
scripts: {
files: [
'game/**/*.js',
'!game/main.js'
],
options: {
spawn: false,
livereload: LIVERELOAD_PORT
},
tasks: ['build']
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, 'dist')
];
}
}
}
},
open: {
server: {
path: 'http://localhost:9000'
}
},
copy: {
dist: {
files: [
// includes files within path and its sub-directories
{ expand: true, src: ['assets/**'], dest: 'dist/' },
{ expand: true, flatten: true, src: ['game/plugins/*.js'], dest: 'dist/js/plugins/' },
{ expand: true, flatten: true, src: ['bower_components/**/build/*.js'], dest: 'dist/js/' },
{ expand: true, src: ['css/**'], dest: 'dist/' },
{ expand: true, src: ['index.html'], dest: 'dist/' }
]
}
},
browserify: {
build: {
src: ['game/main.js'],
dest: 'dist/js/game.js'
}
}
});

grunt.registerTask('build', ['buildBootstrapper', 'browserify','copy']);
grunt.registerTask('serve', ['build', 'connect:livereload', 'open', 'watch']);
grunt.registerTask('default', ['serve']);
grunt.registerTask('prod', ['build', 'copy']);

}
grunt.registerTask('buildBootstrapper', 'builds the bootstrapper file correctly', function() {
var stateFiles = grunt.file.expand('game/states/*.js');
var gameStates = [];
var statePattern = new RegExp(/(\w+).js$/);
stateFiles.forEach(function(file) {
var state = file.match(statePattern)[1];
if (!!state) {
gameStates.push({shortName: state, stateName: _.capitalize(state) + 'State'});
}
});
config.gameStates = gameStates;
console.log(config);
var bootstrapper = grunt.file.read('templates/_main.js.tpl');
bootstrapper = grunt.template.process(bootstrapper,{data: config});
grunt.file.write('game/main.js', bootstrapper);
});
};
Binary file added assets/preloader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/yeoman-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions bower.json
@@ -0,0 +1,7 @@
{
"name": "ludumdare29",
"version": "0.0.0",
"dependencies": {
"phaser-official": "2.0.2"
}
}
46 changes: 46 additions & 0 deletions bower_components/phaser-official/.bower.json
@@ -0,0 +1,46 @@
{
"name": "phaser",
"version": "2.0.2",
"homepage": "http://phaser.io",
"authors": [
"photonstorm <rich@photonstorm.com>"
],
"description": "A fun, free and fast 2D game framework for making HTML5 games for desktop and mobile, supporting Canvas and WebGL.",
"main": "build/phaser.js",
"keywords": [
"html5",
"game",
"games",
"framework",
"canvas",
"WebGL",
"tilemaps",
"physics",
"sprites",
"fonts",
"images",
"audio",
"Web",
"Audio",
"touch",
"input",
"mobile"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"_release": "2.0.2",
"_resolution": {
"type": "version",
"tag": "v2.0.2",
"commit": "5b73bb21bb74c2b3d4b9dd7a4518cec40e019d58"
},
"_source": "git://github.com/photonstorm/phaser.git",
"_target": "2.0.2",
"_originalSource": "phaser-official"
}
74 changes: 74 additions & 0 deletions bower_components/phaser-official/CONTRIBUTING.md
@@ -0,0 +1,74 @@
#How to contribute

It's important to us that you feel you can contribute towards the evolution of Phaser. This can take many forms: from helping to fix bugs or improve the docs, to adding in new features to the source. This guide should help you in making that process as smooth as possible.


##Reporting issues

[GitHub Issues][0] is the place to report bugs you may have found in either the core library or any of the examples that are part of the repository. When submitting a bug please do the following:

1. **Search for existing issues.** Your bug may have already been fixed or addressed in a development branch version of Phaser, so be sure to search the issues first before putting in a duplicate issue.

2. **Not sure if it's a bug?.** Then please ask on the forum. If something is blatantly wrong then post it to github. But if you feel it might just be because you're not sure of expected behaviour, then it might save us time, and get you a response faster, if you post it to the Phaser forum instead.

3. **Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, runnable, code example that reproduces the problem you have.

4. **Include a live example.** After narrowing your code down to only the problem areas, make use of [jsFiddle][1], [jsBin][2], or a link to your live site so that we can view a live example of the problem.

5. **Share as much information as possible.** Include browser version affected, your OS, version of the library, steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed.


##Pixi and Phaser

It's important to understand that internally Phaser uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) for all rendering. It's possible you may find a bug that is generated on the Pixi level rather than Phaser. You're welcome to still report the issue of course, but if you get a reply saying we think it might be a Pixi issue this is what we're talking about :)


##Support Forum

We have a very active [Phaser Support Forum](http://www.html5gamedevs.com/forum/14-phaser/). If you need general support, or are struggling to understand how to do something or need your code checked over, then we would urge you to post it to our forum. There are a lot of friendly devs in there who can help, as well as the core Phaser and Pixi teams, so it's a great place to get support from. You're welcome to report bugs directly on GitHub, but for general support we'd always recommend using the forum first.


##Dev vs. Master

The dev branch of Phaser is our 'current working' version. It is always ahead of the master branch in terms of features and fixes. However it's also bleeding-edge and experimental and we cannot and do not guarantee it will compile or work for you. Very often we have to break things for a few days while we rebuild and patch. So by all means please export the dev branch and contribute towards it, indeed that is where all Pull Requests should be sent, but do so understanding the API may change beneath you.


##Making Changes

To take advantage of our grunt build script and jshint config it will be easiest for you if you have node.js and grunt installed locally.

You can download node.js from [nodejs.org][3]. After it has been installed open a console and run `npm i -g grunt -cli` to install the global `grunt` executable.

After that you can clone the repository and run `npm i` inside the cloned folder. This will install dependencies necessary for building the project. Once that is ready,
make your changes and submit a Pull Request:

- **Send Pull Requests to the `dev` branch.** All Pull Requests must be sent to the `dev` branch, `master` is the latest release and PRs to that branch will be closed.

- **Ensure changes are jshint validated.** Our JSHint configuration file is provided in the repository and you should check against it before submitting.

- **Never commit new builds.** When making a code change you should always run `grunt` which will rebuild the project so you can test, *however* please do not commit these new builds or your PR will be closed. Builds by default are placed in the `dist` folder, to keep them separate from the `build` folder releases.

- **Only commit relevant changes.** Don't include changes that are not directly relevant to the fix you are making. The more focused a PR is, the faster it will get attention and be merged. Extra files changing only whitespace or trash files will likely get your PR closed.


##I don't really like git / node.js, but I can fix this bug

That is fine too. While Pull Requests are the best thing in the world for us, they are not the only way to help. You're welcome to post fixes to our forum or even just email them to us. All we ask is that you still adhere to the guidelines presented here re: JSHint, etc.


##Code Style Guide

- Use 4 spaces for tabs, never tab characters.

- No trailing whitespace, blank lines should have no whitespace.

- Always favor strict equals `===` unless you *need* to use type coercion.

- Follow conventions already in the code, and listen to jshint. Our config is set-up for a reason.

Thanks to Chad for creating the original Pixi.js Contributing file which we adapted for Phaser.

[0]: https://github.com/photonstorm/phaser/issues
[1]: http://jsfiddle.net
[2]: http://jsbin.com/
[3]: http://nodejs.org

0 comments on commit bb7f528

Please sign in to comment.