diff --git a/Gulpfile.coffee b/Gulpfile.coffee index 0236e08..58095f3 100644 --- a/Gulpfile.coffee +++ b/Gulpfile.coffee @@ -50,6 +50,7 @@ bundler = watchify(browserify({ })) gulp.task('ink', () -> + return true # at the moment i don't have a working standalone inklecate return gulp.src([ 'game/ink/*.ink' ]) diff --git a/game/begin.coffee b/game/begin.coffee index 905f0ac..65e119e 100644 --- a/game/begin.coffee +++ b/game/begin.coffee @@ -1,10 +1,10 @@ Story = require('inkjs').Story -musgrave = require('../../game/___.json') +musgrave = require('./ink/fogg.json') class SimpleGame game: null constructor: () -> - @game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', + @game = new Phaser.Game(800, 600, Phaser.AUTO, 'graphic', {preload: this.preload, create: this.create}) preload: () -> @game.stage.backgroundColor = '#ffffff' @@ -13,8 +13,35 @@ class SimpleGame logo = @game.add.sprite(@game.world.centerX, @game.world.centerY, 'logo') logo.anchor.setTo(0.5, 0.5) +continueToNextChoice = (s) -> + while (s.canContinue) + paragraphs = s.Continue().split("\n") + delay = 1000 + for i in paragraphs + if i != "" + html = $.parseHTML(i) + $("#text").append($('

').hide().html(html).fadeIn(delay)) + delay += 500 + scrollTo = $('#options').offset().top + if (s.currentChoices.length > 0) + $("#options").html("").hide() + for choice in s.currentChoices + $("#options").append("

  • #{choice.text}
  • ") + $("#options").fadeIn(800) + $("#options li a").click(() -> + s.ChooseChoiceIndex($(this).data("index")) + continueToNextChoice(s) + return false + ) + else + $("#text").append("

    THE END

    ") + $("#options").html("") + $('html, body').animate({ + scrollTop: scrollTo + }, 800) + $(document).ready(() -> game = new SimpleGame() inkStory = new Story(musgrave) - console.log(inkStory.ContinueMaximally()) + continueToNextChoice(inkStory) ) diff --git a/html/index.html b/html/index.html index 2ff936d..5a57b64 100644 --- a/html/index.html +++ b/html/index.html @@ -11,7 +11,13 @@
    -
    +
    +
    +
    +
    +
    +
      +