Skip to content

Commit 3591a83

Browse files
committed
Basics of game
Design needs to be updated with bootstrap.
0 parents  commit 3591a83

File tree

13 files changed

+201
-0
lines changed

13 files changed

+201
-0
lines changed

.bowerrc

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

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
node_modules/*
3+
lib

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
HTML-game
2+
=========
3+
Install node from nodejs.org. (For server and dependencies)
4+
When you're finished, go to this repo and open a git bash here.
5+
Then, type npm install.
6+
Then, when that's finished, type bower install.
7+
You're now done setting up.
8+
To run the project, type gulp dev.

bower.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "HTML-game",
3+
"version": "0.0.1",
4+
"keywords": [
5+
"HTML"
6+
],
7+
"license": "MIT",
8+
"private": true,
9+
"ignore": [
10+
"**/.*",
11+
"node_modules",
12+
"bower_components",
13+
"test",
14+
"tests"
15+
],
16+
"dependencies": {
17+
"angular": "~1.3.5",
18+
"angular-route": "~1.3.5",
19+
"jquery": "~2.1.1"
20+
}
21+
}

gulpfile.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
var gulp = require('gulp'),
2+
livereload = require('gulp-livereload'),
3+
watch = require('gulp-watch'),
4+
open = require('open'),
5+
plumber = require('gulp-plumber'),
6+
runSequence = require('run-sequence'),
7+
assets = require('gulp-assets'),
8+
clean = require('gulp-clean'),
9+
nodemon = require('gulp-nodemon');
10+
11+
var IN = "working/",
12+
OUT = "build/";
13+
gulp.task('css', function() {
14+
return gulp.src(IN + "index.html")
15+
.pipe(plumber())
16+
.pipe(assets.css())
17+
.pipe(gulp.dest(OUT));
18+
});
19+
20+
gulp.task('clean', function() {
21+
return gulp.src(OUT)
22+
.pipe(clean());
23+
})
24+
25+
gulp.task('openBrowser', function() {
26+
var port = process.env.PORT || 8000;
27+
open('http://localhost:' + port +'#/home');
28+
})
29+
30+
gulp.task('run', function() {
31+
nodemon({
32+
script: 'server/server.js',
33+
watch: 'server/',
34+
ignore: [ 'server/grammar.js' ],
35+
env: { 'NODE_ENV': 'development' }
36+
});
37+
})
38+
39+
gulp.task('html', function() {
40+
return gulp.src(IN + "**/*.html")
41+
.pipe(plumber())
42+
.pipe(gulp.dest(OUT));
43+
})
44+
45+
gulp.task('js', function() {
46+
return gulp.src(IN + "index.html")
47+
.pipe(plumber())
48+
.pipe(assets.js())
49+
.pipe(gulp.dest(OUT));
50+
});
51+
52+
gulp.task('build', ['css', 'js' , 'html']);
53+
54+
gulp.task('livereload', function() {
55+
livereload.listen();
56+
gulp.watch(IN + "**/*", ["build"]);
57+
gulp.watch(OUT + "**/*", livereload.changed);
58+
})
59+
60+
gulp.task('dev', function() {
61+
62+
return runSequence('clean', 'openBrowser', 'run', 'build', 'livereload');
63+
})

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "HTML-game",
3+
"version": "0.0.1",
4+
"description": "HTML-game\r =========",
5+
"main": "index.js",
6+
"dependencies": {
7+
"bower": "^1.3.12",
8+
"connect-livereload": "^0.5.2",
9+
"express": "^4.10.4",
10+
"gulp": "^3.8.10",
11+
"gulp-assets": "^0.1.0",
12+
"gulp-clean": "^0.3.1",
13+
"gulp-livereload": "^2.1.1",
14+
"gulp-nodemon": "^1.0.4",
15+
"gulp-plumber": "^0.6.6",
16+
"gulp-watch": "^3.0.0",
17+
"open": "0.0.5",
18+
"run-sequence": "^1.0.2"
19+
},
20+
"devDependencies": {},
21+
"scripts": {
22+
"test": "echo \"Error: no test specified\" && exit 1"
23+
},
24+
"repository": {
25+
"type": "git",
26+
"url": "https://github.com/maneesht/HTML-game.git"
27+
},
28+
"author": "Maneesh Tewani",
29+
"license": "ISC",
30+
"bugs": {
31+
"url": "https://github.com/maneesht/HTML-game/issues"
32+
},
33+
"homepage": "https://github.com/maneesht/HTML-game"
34+
}

server/server.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var express = require('express'),
2+
livereload = require('connect-livereload'),
3+
router = express.Router();
4+
5+
var serverPort = process.env.Port || 8000;
6+
var server = express();
7+
var workingDir = "build/";
8+
server.use(livereload());
9+
server.use('/CSS', express.static(workingDir + 'CSS'));
10+
server.use('/lib', express.static(workingDir + 'lib'));
11+
server.get("/", function(req,res) {
12+
console.log("Hello!");
13+
res.sendfile(workingDir + "index.html");
14+
});
15+
server.get('/*.js', function(req,res) {
16+
res.sendfile(workingDir+ req.params[0] + '.js');
17+
})
18+
server.get('/*.html', function (req, res) {
19+
res.sendfile(workingDir + req.params[0] + '.html');
20+
});
21+
console.log("server running on port ", serverPort);
22+
server.listen(serverPort);

working/app/app.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
angular.module('html_game' , ['ngRoute', 'app.landing', 'app.game'])
2+
.config(function($routeProvider) {
3+
$routeProvider.when('/home', {
4+
templateUrl: "app/home/home.html",
5+
controllerAs: "home",
6+
controller: "landingCtrl"
7+
})
8+
.when('/game', {
9+
templateUrl:"app/game/game.html",
10+
controller: "gameCtrl",
11+
controllerAs: "game"
12+
})
13+
});

working/app/game/game.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<textarea style="height: 50%; width:100%" ng-model="html"></textarea>
2+
<div id="container"></div>
3+
<button ng-click="compile()">Check</button>

working/app/game/game.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
angular.module('app.game', [])
2+
.controller('gameCtrl', function($scope){
3+
$scope.$watch('html', function() {
4+
$("#container").empty();
5+
$("#container").append($scope.html);
6+
})
7+
})
8+

working/app/home/home.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div>Welcome!</div>
2+
<button ng-click="home.playGame()">Play Game!</button>

working/app/home/home.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
angular.module('app.landing', [])
2+
.controller('landingCtrl', function($location){
3+
this.playGame = function() {
4+
$location.url('/game')
5+
}
6+
})

working/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html ng-app="html_game">
2+
<head>
3+
<title>HTML Game</title>
4+
</head>
5+
<body>
6+
<script src="lib/angular/angular.js"></script>
7+
<script src="lib/jquery/dist/jquery.js"></script>
8+
<script src="lib/angular-route/angular-route.js"></script>
9+
<script src="app/app.js"></script>
10+
<script src="app/home/home.js"></script>
11+
<script src="app/game/game.js"></script>
12+
<div ng-view></div>
13+
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)