diff --git a/Gulpfile.coffee b/Gulpfile.coffee deleted file mode 100644 index 1ed860c..0000000 --- a/Gulpfile.coffee +++ /dev/null @@ -1,122 +0,0 @@ -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') -shell = require('gulp-shell') - -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)) - -# Ink files -ink = (target) -> - return () -> - return gulp.src(['game/*.ink']).pipe(gulp.dest(target)).pipe(shell([ - 'inklecate <%= file.path %>' - ])) - -gulp.task('html', html('./build')) -gulp.task('img', img('./build/img')) -gulp.task('audio', audio('./build/audio')) -gulp.task('ink', ink('./build')) - -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', 'ink', 'img', 'coffee', 'audio']) - -gulp.task('serve', ['build'], () -> - browserSync({ - server: { - baseDir: 'build' - } - }) - - gulp.watch(['./html/*.html'], ['html']) - gulp.watch(['./game/*.json'], ['ink']) - 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('ink-dist', ink('./dist')) -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', - 'ink-dist', - 'img-dist', - 'coffee-dist', - 'audio-dist', - 'legal-dist' -]) - -gulp.task('zip', ['dist'], () -> - return gulp.src('dist/**') - .pipe(zip('dist.zip')) - .pipe(gulp.dest('.')) -) diff --git a/README.md b/README.md index 0ebd7c8..cb84c0d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Console commands to start working 1. `git clone` -2. `npm install` -3. `gulp serve` - -Not included: ink compiler from Ink source to JSON. +2. `npm install` or better `pnpm install` +3. Compile your ink files with inklecate to JSON (compiler not included) +3. `webpack prod` and you'll have the game in the `build` folder. diff --git a/game/game.coffee b/game/game.coffee deleted file mode 100644 index 5ca811a..0000000 --- a/game/game.coffee +++ /dev/null @@ -1,65 +0,0 @@ -inkjs = require("inkjs") - -saveChoice = (index) -> - window.progress.push(index) - localStorage.setItem("progress", JSON.stringify(window.progress)) - -displayText = (s, interactive = true) -> - while (s.canContinue) - paragraphs = s.Continue().split("\n") - if interactive - delay = 1000 - for i in paragraphs - if i != "" - html = $.parseHTML(i) - block = $('
').html(html) - if interactive - block.hide() - $("#content").append(block) - if interactive - block.fadeIn(delay) - delay += 500 - -continueToNextChoice = (s) -> - displayText(s, true) - scrollTo = $('#options').offset().top - if (s.currentChoices.length > 0) - $("#options").html("").hide() - for choice in s.currentChoices - $("#options").append("
THE END
") - $("#options").html("") - $('html, body').animate({ - scrollTop: scrollTo - }, 800) - -loadGame = (s) -> - for index in window.progress - displayText(s, false) - s.ChooseChoiceIndex(index) - -clearProgress = () -> - window.progress = [] - -$.ajax({ - url: 'fogg.ink.json', - dataType: 'text', - success: (data) -> - progress = localStorage.getItem("progress") - if progress? - window.progress = JSON.parse(progress) - else - window.progress = [] - s = new inkjs.Story(data) - if window.progress != [] - loadGame(s) - continueToNextChoice(s) -}) diff --git a/html/index.html b/html/index.html index 93b1ee1..20bcf89 100644 --- a/html/index.html +++ b/html/index.html @@ -3,14 +3,19 @@