Skip to content

Commit b7913a2

Browse files
committed
basics are working
0 parents  commit b7913a2

26 files changed

+644
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
temp/

.jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"node": true,
3+
"esnext": true,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": true,
7+
"eqeqeq": true,
8+
"immed": true,
9+
"indent": 4,
10+
"latedef": true,
11+
"newcap": true,
12+
"noarg": true,
13+
"quotmark": "single",
14+
"regexp": true,
15+
"undef": true,
16+
"unused": true,
17+
"strict": true,
18+
"trailing": true,
19+
"smarttabs": true,
20+
"white": true
21+
}

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- '0.8'
4+
- '0.10'

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2013 Louis Acresti
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# generator-combo [![Build Status](https://secure.travis-ci.org/namuol/generator-combo.png?branch=master)](https://travis-ci.org/namuol/generator-combo)
2+
3+
A combo game template generator for [Yeoman](http://yeoman.io).
4+
5+
6+
## Getting Started
7+
8+
### What is Yeoman?
9+
10+
Trick question. It's not a thing. It's this guy:
11+
12+
![](http://i.imgur.com/JHaAlBJ.png)
13+
14+
Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
15+
16+
Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*
17+
18+
```
19+
$ npm install -g yo
20+
```
21+
22+
### Yeoman Generators
23+
24+
Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
25+
26+
To install generator-combo from npm, run:
27+
28+
```
29+
$ npm install -g generator-combo
30+
```
31+
32+
Finally, initiate the generator:
33+
34+
```
35+
$ yo combo
36+
```
37+
38+
### Getting To Know Yeoman
39+
40+
Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
41+
42+
If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
43+
44+
45+
## License
46+
47+
[MIT License](http://en.wikipedia.org/wiki/MIT_License)

app/index.coffee

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
path = require 'path'
2+
yeoman = require 'yeoman-generator'
3+
fs = require 'fs'
4+
5+
module.exports = class ComboGenerator extends yeoman.generators.Base
6+
constructor: (args, options, config) ->
7+
yeoman.generators.Base.apply this, arguments
8+
@on 'end', ->
9+
@installDependencies skipInstall: options['skip-install']
10+
11+
@pkg = JSON.parse @readFileAsString path.join __dirname, '../package.json'
12+
13+
unless @env.options.coffee?
14+
@option('coffee')
15+
16+
# attempt to detect if user is using CS or not
17+
# if cml arg provided, use that; else look for the existence of cs
18+
if (!@options.coffee && @expandFiles('/src/**/*.coffee', {}).length > 0)
19+
@options.coffee = true
20+
21+
@env.options.coffee = @options.coffee
22+
23+
24+
if @env.options.coffee
25+
@sourceRoot path.join __dirname, '/templates/coffeescript'
26+
@ext = '.coffee'
27+
else
28+
@sourceRoot path.join __dirname, '/templates/javascript'
29+
@ext = '.js'
30+
31+
@combo = """ _____ _____ ___ _________ _____
32+
/ __ \\| _ || \\/ || ___ \\| _ |
33+
| / \\/| | | || . . || |_/ /| | | |
34+
| | | | | || |\\/| || ___ \\| | | |
35+
| \\__/\\\\ \\_/ /| | | || |_/ /\\ \\_/ /
36+
\\____/ \\___/ \\_| |_/\\____/ \\___/
37+
38+
"""
39+
40+
askFor: ->
41+
cb = @async()
42+
43+
# have Yeoman greet the user.
44+
console.log @combo
45+
46+
prompts = [
47+
name: 'gameName'
48+
message: 'What do you want to call your game?'
49+
default: 'Combo Game'
50+
]
51+
52+
@prompt prompts, (props) =>
53+
@gameName = props.gameName
54+
cb()
55+
56+
app: ->
57+
@template '_Gruntfile'+@ext, 'Gruntfile'+@ext
58+
59+
@mkdir 'src'
60+
@mkdir 'src/assets'
61+
62+
@template 'src/_Game'+@ext, 'src/' + @_.camelize(@gameName)+@ext
63+
@template 'src/_main'+@ext, 'src/main'+@ext
64+
@template '../common/src/_index.html', 'src/index.html'
65+
@copy 'src/mainWrapper.js', 'src/mainWrapper.js'
66+
67+
# package configs/dotfiles
68+
@template '../common/_package.json', 'package.json'
69+
@template '../common/_bower.json', 'bower.json'
70+
@copy '../common/bowerrc', '.bowerrc'
71+
@copy '../common/editorconfig', '.editorconfig'
72+
@copy '../common/gitignore', '.gitignore'
73+
74+
# fs.symlinkSync path.join(@destinationRoot(), '../support/combo'), path.join(@destinationRoot(), 'src/combo/src'), 'dir'

app/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('coffee-script');
2+
module.exports = require('./index.coffee');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = (grunt) ->
2+
config =
3+
pkg: grunt.file.readJSON 'package.json'
4+
connect:
5+
server:
6+
options:
7+
port: 9042
8+
base: 'src'
9+
directory: 'src'
10+
keepalive: true
11+
copy:
12+
html:
13+
expand: true
14+
cwd: 'src'
15+
src: ['**/*.html','!support/**']
16+
dest: 'dist'
17+
assets:
18+
expand: true
19+
cwd: 'src'
20+
src: ['**/assets/**','!support/**']
21+
dest: 'dist'
22+
requirejs:
23+
build:
24+
options:
25+
packages: [
26+
name: 'cs',
27+
location: 'support/require-cs',
28+
main: 'cs'
29+
,
30+
name: 'coffee-script',
31+
location: 'support/coffee-script',
32+
main: 'index'
33+
,
34+
name: 'combo',
35+
location: 'support/combo/src/combo'
36+
]
37+
baseUrl: 'src'
38+
name: 'support/almond/almond'
39+
include: 'mainWrapper'
40+
insertRequire: ['mainWrapper']
41+
exclude: ['coffee-script']
42+
out: "dist/main-built.js"
43+
44+
grunt.initConfig config
45+
46+
grunt.loadNpmTasks 'grunt-contrib-copy'
47+
grunt.loadNpmTasks 'grunt-contrib-requirejs'
48+
grunt.loadNpmTasks 'grunt-contrib-connect'
49+
50+
grunt.registerTask 'default', ['copy', 'requirejs']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
define '<%= _.classify(gameName) %>', [
2+
'cs!combo/cg'
3+
], (
4+
cg
5+
) ->
6+
7+
<%= _.classify(gameName) %> = (App, forceCanvas=false) ->
8+
class _<%= _.classify(gameName) %> extends App
9+
forceCanvas: forceCanvas
10+
init: ->
11+
super
12+
13+
cg.log 'Combo game initialized!'
14+
15+
return _<%= _.classify(gameName) %>
16+
17+
return <%= _.classify(gameName) %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
define [
2+
'cs!combo/index'
3+
'cs!combo/web/WebApp'
4+
'cs!<%= _.classify(gameName) %>'
5+
], (
6+
combo
7+
WebApp
8+
<%= _.classify(gameName) %>
9+
) ->
10+
11+
return ->
12+
combo.init()
13+
14+
getParameterByName = (name) ->
15+
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]")
16+
regex = new RegExp("[\\?&]" + name + "=([^&#]*)")
17+
results = regex.exec(location.search)
18+
return if results == null then "" else decodeURIComponent(results[1].replace(/\+/g, " "))
19+
20+
forceCanvas = parseInt(getParameterByName('forceCanvas'))
21+
22+
game = new (<%= _.classify(gameName) %>(WebApp, forceCanvas))('container')
23+
24+
window.game = game
25+
26+
game.run()
27+
28+
pleasewait = document.getElementById 'pleasewait'
29+
pleasewait.style.display = 'none'
30+
31+
container = document.getElementById 'container'
32+
container.style.display = 'inherit'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require.config({
2+
packages: [
3+
{
4+
name: 'cs',
5+
location: 'support/require-cs',
6+
main: 'cs'
7+
},
8+
{
9+
name: 'coffee-script',
10+
location: 'support/coffee-script',
11+
main: 'index'
12+
},
13+
{
14+
name: 'combo',
15+
location: 'support/combo/src/combo'
16+
}
17+
]
18+
});
19+
20+
require([
21+
'cs!main',
22+
'coffee-script'
23+
], function(main) {
24+
main();
25+
});

app/templates/common/_bower.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "<%= _.slugify(gameName) %>",
3+
"private": true,
4+
"dependencies": {
5+
"almond": "~0.2.6",
6+
"requirejs": "~2.1.9",
7+
"require-cs": "[email protected]:Jovianware/require-cs.git#0.4.5",
8+
"combo": "/Users/louman/dev/combo.js-native/support/combo"
9+
}
10+
}

app/templates/common/_package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "<%= _.slugify(gameName) %>",
3+
"private": true,
4+
"dependencies": {
5+
"grunt": "~0.4.1",
6+
"grunt-contrib-requirejs": "~0.4.0",
7+
"grunt-contrib-copy": "~0.4.0"
8+
},
9+
"devDependencies": {
10+
"grunt-contrib-watch": "~0.3.1",
11+
"grunt-contrib-connect": "~0.5.0"
12+
},
13+
"engines": {
14+
"node": ">=0.8.0"
15+
}
16+
}

app/templates/common/bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "src/support"
3+
}

app/templates/common/editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

app/templates/common/gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
src/support
3+
dist

0 commit comments

Comments
 (0)