diff --git a/notes.org b/notes.org index b1bf741..4b06934 100644 --- a/notes.org +++ b/notes.org @@ -7,6 +7,7 @@ Title: Entire game on one screen * TODO HUD ** hud: energie progress bar :aaron: +** i key * TODO OUTRO ** win screen \ No newline at end of file diff --git a/public/images/speechbubbles.png b/public/images/speechbubbles.png index 233fb02..2254b0c 100644 Binary files a/public/images/speechbubbles.png and b/public/images/speechbubbles.png differ diff --git a/public/images/speechbubbles.psd b/public/images/speechbubbles.psd index d1df1c2..0c5e3dc 100644 Binary files a/public/images/speechbubbles.psd and b/public/images/speechbubbles.psd differ diff --git a/src/game.coffee b/src/game.coffee index 2b57577..fcf42c2 100644 --- a/src/game.coffee +++ b/src/game.coffee @@ -13,6 +13,31 @@ app.game = @hud.start() @speechbubble.start() + @intro = true + @startIntro() + + startIntro: -> + @speechbubble.setFix 90, 27 + @speechbubble.say 'help', 2000 + + @timeout = window.setTimeout @intro2, 3000 + + intro2: => + app.game.speechbubble.say 'damn', 2000 + app.game.timeout = window.setTimeout app.game.intro3, 3000 + + intro3: => + app.game.speechbubble.say 'need', 3500 + app.game.timeout = window.setTimeout app.game.intro4, 4500 + + intro4: => + app.game.speechbubble.say 'collect', 3500 + app.game.timeout = window.setTimeout app.game.introEnd, 3500 + + introEnd: => + @intro = false + app.game.speechbubble.setMouse() + render: -> for tile, i in @map y = Math.floor(i/20) diff --git a/src/speechbubble.coffee b/src/speechbubble.coffee index d32f2c5..83c5e4c 100644 --- a/src/speechbubble.coffee +++ b/src/speechbubble.coffee @@ -1,8 +1,18 @@ app.game.speechbubble = start: -> @sprite = [0, 0, 27, 13] + @positioning = 'mouse' - say: (text) -> + setFix: (x, y) -> + @x = x + @y = y + + @positioning = 'fixed' + + setMouse: -> + @positioning = 'mouse' + + say: (text, timeout = 1000) -> clearTimeout(@timeout) if @timeout switch text @@ -10,12 +20,23 @@ app.game.speechbubble = when 'toofar' then @sprite = [0, 13, 90, 13] when 'nores' then @sprite = [0, 26, 90, 13] when 'nosel' then @sprite = [0, 39, 90, 13] + when 'damn' then @sprite = [0, 52, 90, 13] + when 'need' then @sprite = [0, 65, 90, 13] + when 'collect' then @sprite = [0, 78, 90, 13] @visible = true - @timeout = window.setTimeout @hide, 1000 + @timeout = window.setTimeout @hide, timeout hide: => app.game.speechbubble.visible = false render: -> - app.layer.drawRegion app.images.speechbubbles, @sprite, app.game.mouseX+5, app.game.mouseY-15 if @visible \ No newline at end of file + switch @positioning + when 'mouse' + x = app.game.mouseX+5 + y = app.game.mouseY-15 + when 'fixed' + x = @x + y = @y + + app.layer.drawRegion app.images.speechbubbles, @sprite, x, y if @visible \ No newline at end of file