Initial commit
This commit is contained in:
commit
e88a3c9022
110
Gulpfile.coffee
Normal file
110
Gulpfile.coffee
Normal file
|
@ -0,0 +1,110 @@
|
|||
watchify = require('watchify')
|
||||
browserify = require('browserify')
|
||||
browserSync = require('browser-sync')
|
||||
gulp = require('gulp')
|
||||
source = require('vinyl-source-stream')
|
||||
gutil = require('gulp-util')
|
||||
coffeify = require('coffeeify')
|
||||
coffee = require("gulp-coffee")
|
||||
uglify = require('gulp-uglify')
|
||||
buffer = require('vinyl-buffer')
|
||||
zip = require('gulp-zip')
|
||||
concat = require('gulp-concat')
|
||||
|
||||
reload = browserSync.reload
|
||||
|
||||
html = (target) ->
|
||||
return () ->
|
||||
return gulp.src(['html/index.html', 'html/en.html']).pipe(gulp.dest(target))
|
||||
|
||||
# Images
|
||||
img = (target) ->
|
||||
return () ->
|
||||
return gulp.src(['img/*.png', 'img/*.jpeg', 'img/*.jpg']).pipe(gulp.dest(target))
|
||||
|
||||
# Audio assets
|
||||
audio = (target) ->
|
||||
return () ->
|
||||
return gulp.src(['audio/*.mp3']).pipe(gulp.dest(target))
|
||||
|
||||
gulp.task('html', html('./build'))
|
||||
gulp.task('img', img('./build/img'))
|
||||
gulp.task('audio', audio('./build/audio'))
|
||||
|
||||
bundler = watchify(browserify({
|
||||
entries: ["./build/game/main.coffee"]
|
||||
debug: true
|
||||
transform: [coffeify]
|
||||
}))
|
||||
|
||||
bundle = () ->
|
||||
return bundler.bundle()
|
||||
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
|
||||
.pipe(source('bundle.js'))
|
||||
.pipe(gulp.dest('./build/game'))
|
||||
|
||||
gulp.task('concatCoffee', () ->
|
||||
return gulp.src([
|
||||
'./game/game.coffee',
|
||||
]).pipe(concat('./main.coffee')).pipe(gulp.dest('./build/game'))
|
||||
)
|
||||
|
||||
gulp.task('coffee', ['concatCoffee'], bundle)
|
||||
|
||||
bundler.on('update', bundle)
|
||||
bundler.on('log', gutil.log)
|
||||
|
||||
gulp.task('build', ['html', 'img', 'coffee', 'audio'])
|
||||
|
||||
gulp.task('serve', ['build'], () ->
|
||||
browserSync({
|
||||
server: {
|
||||
baseDir: 'build'
|
||||
}
|
||||
})
|
||||
|
||||
gulp.watch(['./html/*.html'], ['html'])
|
||||
gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img'])
|
||||
gulp.watch(['./game/*.coffee'], ['coffee']);
|
||||
|
||||
gulp.watch(
|
||||
['./build/game/bundle.js', './build/img/*', './build/index.html'],
|
||||
browserSync.reload)
|
||||
)
|
||||
|
||||
gulp.task('html-dist', html('./dist'))
|
||||
gulp.task('img-dist', img('./dist/img'))
|
||||
gulp.task('audio-dist', audio('./dist/audio'))
|
||||
gulp.task('legal-dist', () ->
|
||||
return gulp.src(['LICENSE.txt'])
|
||||
.pipe(gulp.dest("./dist"))
|
||||
)
|
||||
|
||||
distBundler = browserify({
|
||||
debug: false,
|
||||
entries: ['./build/game/main.coffee'],
|
||||
transform: ['coffeeify']
|
||||
})
|
||||
|
||||
gulp.task('coffee-dist', ['concatCoffee'], () ->
|
||||
return distBundler.bundle()
|
||||
.pipe(source('bundle.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify())
|
||||
.on('error', gutil.log)
|
||||
.pipe(gulp.dest('./dist/game'))
|
||||
)
|
||||
|
||||
gulp.task('dist', [
|
||||
'html-dist',
|
||||
'img-dist',
|
||||
'coffee-dist',
|
||||
'audio-dist',
|
||||
'legal-dist'
|
||||
])
|
||||
|
||||
gulp.task('zip', ['dist'], () ->
|
||||
return gulp.src('dist/**')
|
||||
.pipe(zip('dist.zip'))
|
||||
.pipe(gulp.dest('.'))
|
||||
)
|
1
build/fogg.ink.json
Normal file
1
build/fogg.ink.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"inkVersion":11,"root":[[["^I looked at Monsieur Fogg","\n",["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^... and I could contain myself no longer.",null],"c":[{"f()":".^.^.s"},"\n","^'What is the purpose of our journey, Monsieur?'","\n","^'A wager,' he replied.","\n",[["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^'A wager!'",null],"c":[{"f()":".^.^.s"},"^ I returned.","\n","\n","^He nodded.","\n",[["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^'But surely that is foolishness!'",null],"c":[{"f()":".^.^.s"},"\n",{"->":".^.^.^.g-0"},{"#f":5}]}],["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^'A most serious matter then!'",null],"c":[{"f()":".^.^.s"},"\n",{"->":".^.^.^.g-0"},{"#f":5}]}],{"g-0":["^He nodded again.","\n",["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^'But can we win?'",null],"c":[{"f()":".^.^.s"},"\n","^'That is what we will endeavour to find out,' he answered.","\n",{"->":"0.g-0.2.c.6.g-0"},{"#f":5}]}],["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^'A modest wager, I trust?'",null],"c":[{"f()":".^.^.s"},"\n","^'Twenty thousand pounds,' he replied, quite flatly.","\n",{"->":"0.g-0.2.c.6.g-0"},{"#f":5}]}],["ev","str",{"f()":".^.s"},"/str","str","^.","/str","/ev",{"*":".^.c","flg":22},{"s":["^I asked nothing further of him then",null],"c":[{"f()":".^.^.s"},"^, and after a final, polite cough, he offered nothing more to me. ","<>","\n","\n",{"->":"0.g-0.2.c.6.g-0"},{"#f":5}]}],null]}],{"#f":5}]}],["ev","str",{"f()":".^.s"},"/str","str","^.'","/str","/ev",{"*":".^.c","flg":22},{"s":["^'Ah",null],"c":[{"f()":".^.^.s"},"^,' I replied, uncertain what I thought.","\n","\n",{"->":".^.^.^.g-0"},{"#f":5}]}],{"g-0":["^After that, ","<>","\n",{"->":"0.g-0.g-1"},null]}],{"#f":5}]}],["ev","str",{"f()":".^.s"},"/str","/ev",{"*":".^.c","flg":18},{"s":["^... but I said nothing",null],"c":[{"f()":".^.^.s"},"^ and ","<>","\n","\n",{"->":"0.g-0.g-1"},{"#f":5}]}],{"g-1":["^we passed the day in silence.","\n",["end",{"#n":"g-2"}],null],"#n":"g-0"}],null],"done",null]}
|
26
game/game.coffee
Normal file
26
game/game.coffee
Normal file
|
@ -0,0 +1,26 @@
|
|||
inkjs = require("inkjs")
|
||||
|
||||
continueToNextChoice = (s) ->
|
||||
while (s.canContinue)
|
||||
$("#content").append("<p>#{s.Continue()}</p>")
|
||||
if (s.currentChoices.length > 0)
|
||||
$("#options").html("")
|
||||
for choice in s.currentChoices
|
||||
$("#options").append("<li><a href='#' id='choice-#{choice.index}' data-index=#{choice.index}>#{choice.text}</a></li>")
|
||||
$("#options li a").click(() ->
|
||||
s.ChooseChoiceIndex($(this).data("index"))
|
||||
continueToNextChoice(s)
|
||||
return false
|
||||
)
|
||||
else
|
||||
$("#content").append("<p>THE END</p>")
|
||||
$("#options").html("")
|
||||
|
||||
fetch('../fogg.ink.json')
|
||||
.then((response) ->
|
||||
return response.text()
|
||||
)
|
||||
.then((data) ->
|
||||
s = new inkjs.Story(data)
|
||||
continueToNextChoice(s)
|
||||
)
|
27
html/index.html
Normal file
27
html/index.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,400italic|PT+Sans+Caption' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div id="page" class="container">
|
||||
<div class="row">
|
||||
<div id="content" class="col-md-12"></div>
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<ul id="options">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CDN JS Libraries -->
|
||||
<script src="//code.jquery.com/jquery-2.2.0.min.js"></script>
|
||||
|
||||
<script src="game/bundle.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
22
package.json
Normal file
22
package.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"dependencies": {
|
||||
},
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"babelify": "^6.0.2",
|
||||
"browser-sync": "^2.6.0",
|
||||
"browserify": "^9.0.8",
|
||||
"browserify-shim": "^3.8.8",
|
||||
"coffeeify": "^1.0.0",
|
||||
"coffee-script": "^1.10.0",
|
||||
"gulp": "^3.8.11",
|
||||
"gulp-uglify": "^1.2.0",
|
||||
"gulp-coffee": "^2.3.1",
|
||||
"gulp-util": "^3.0.4",
|
||||
"gulp-zip": "^3.0.2",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0",
|
||||
"watchify": "^3.1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue