Skip to content

Commit

Permalink
Merge pull request #14 from MattSurabian/pixi
Browse files Browse the repository at this point in the history
PixiJS Refactor
  • Loading branch information
MattSurabian committed Mar 3, 2016
2 parents af24f38 + 76d705a commit ffe2153
Show file tree
Hide file tree
Showing 118 changed files with 51,817 additions and 12,915 deletions.
65 changes: 65 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"esnext": true,
"disallowMixedSpacesAndTabs": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowTrailingWhitespace": true,
"maximumLineLength": 150,
"requireCommaBeforeLineBreak": true,
"requireLineFeedAtFileEnd": true,
"requireSpaceAfterBinaryOperators": [
"=",
",",
"+",
"-",
"/",
"*",
"==",
"===",
"!=",
"!==",
":",
"&&",
"||"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBinaryOperators": [
"=",
"+",
"-",
"/",
"*",
"==",
"===",
"!=",
"!==",
"&&",
"||"
],
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"safeContextKeyword": ["_this"],
"validateQuoteMarks": {
"escape": true,
"mark": "'"
}
}
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esnext": true
}
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
# DUCK HUNT JS v2.0
# DUCK HUNT JS v3.0

[Play the game](http://mattsurabian.com/duckhunt)
[Play the game](http://duckhuntjs.com)

This is an implementation of DuckHunt in javascript using HTML5 audio.
This is an implementation of DuckHunt in Javascript and HTML5. It uses the PixiJS rendering engine, Green Sock Animations, Howler, and Bluebird Promises.

All of the game logic is in the duckhunt directory. This project uses [gulp](http://gulpjs.com/) to build two concatenated js files;
one representing all of our game logic the other representing necessary javascript library dependencies.
## Rendering
This game supports WebGL and Canvas rendering via the PixiJS rendering engine.

This refactor of the game relies on custom events to control game flow which has cut down a bit on the "animation callback hell"
faced in version 1.
## Audio
This game will attempt to use the WebAudioAPI and fallback to HTML5 Audio if necessary. Audio is loaded and controlled via HowlerJS.

## Tweening
The animations in this game are a combination of PixiJS MovieClips built from sprite images and tweens. Since PixiJS doesn't provide a tweening API, Green Sock was used.

## Game Logic
The flow of this game is managed using Javascript. The main chunks of business logic are implemented as ES6 classes which are transpiled to ES5 using Babel.

## Working With This Repo

1. Clone the repo into a directory of your choice
1. `cd` into that directory and run `npm install`
1. Use the `gulp dev` task during active development. This task automatically builds all necessary JS files and triggers the [livereload browser extension](http://livereload.com/extensions/) to do its thing and reload the page when changes are detected in the `lib` and `duckhunt` directories.
1. If you want to manually cut a build of the JS the default gulp task will lint, concatenate, and minify the project's javascript files it into the build directory.
- You must have [nodejs](https://nodejs.org/) installed. This project also uses `gulp`. Installing it globally with `npm install -g gulp` is optional, though if you choose not to install it globally you'll have to use `npm run gulp -- TASK` instead of just `gulp TASK` when following the rest of this README.
- Clone the repo into a directory of your choice
- `cd` into that directory and run `npm install`
- Use `gulp serve` to start a local webserver which will make the site available at http://localhost:8080/. Cross origin errors prevent this project from being accessed in the browser with the `file://` protocol.
- If you're interested in modifying the code, use the `gulp dev` task to serve the site on http://localhost:8080/ and trigger automatic builds and reloads of the page when changes are detected in the `src` directory.
- If you want to manually cut a build of the JS, the default gulp task will run jshint, ensure code style compliance via JSCS, transpile to ES5 and browserify everything into a single `duckhunt.js` file in the `dist` folder. The default task also constructs new image and audio sprite sheets and their respecitve manifests.

## Bugs
Please report bugs as [issues](https://github.com/MattSurabian/DuckHunt-JS/issues).

## Contributing
Pull requests are welcome! Please ensure `jscs` and `jshint` compliance and include any built files.
1 change: 0 additions & 1 deletion build/duckhunt.min.js

This file was deleted.

7 changes: 0 additions & 7 deletions build/libs.min.js

This file was deleted.

50 changes: 50 additions & 0 deletions dist/audio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"urls": [
"audio.ogg",
"audio.mp3"
],
"sprite": {
"barkDucks": [
0,
2403.265306122449
],
"champ": [
4000,
9639.183673469388
],
"gunSound": [
15000,
504.01360544217687
],
"laugh": [
17000,
1368.0045351473923
],
"loserSound": [
20000,
3631.0204081632664
],
"ohYeah": [
25000,
1071.020408163264
],
"quacking": [
28000,
6817.959183673466,
true
],
"quak": [
36000,
783.6734693877575
],
"sniff": [
38000,
1985.306122448982,
true
],
"thud": [
41000,
548.571428571428
]
}
}
Binary file added dist/audio.mp3
Binary file not shown.
Binary file added dist/audio.ogg
Binary file not shown.
Loading

0 comments on commit ffe2153

Please sign in to comment.