diff --git a/src/app.coffee b/src/app.coffee index 174df38..524253e 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -5,7 +5,7 @@ app = playground( smoothing: false, create: -> - @loadImages "layers", "active", "progress", "selected", "entities", "hud", "actions", "speechbubbles", "deadtiles", "layerdetails", "entitydetails", "buildinfo", "cursor", "info", "end" + @loadImages "layers", "active", "progress", "selected", "entities", "hud", "actions", "speechbubbles", "deadtiles", "layerdetails", "entitydetails", "buildinfo", "cursor", "info", "end", "intro1", "intro2", "intro3", "intro4", "titlescreen" @currentHoveredTile = new Tile ready: -> diff --git a/src/game.coffee b/src/game.coffee index cd10bda..7fbfba9 100644 --- a/src/game.coffee +++ b/src/game.coffee @@ -15,32 +15,34 @@ app.game = @hud.start() @speechbubble.start() - @cutScene = true - @cutSceneImage = app.images.intro1 - + @cutScene = false @intro = false - @startCutScene() + @titleScreen = true - # TODO: Refactor this whole crap ... I can't belive I am writing rthis ... + # TODO: Refactor this whole crap ... I can't belive I am writing this ... startCutScene: -> - window.setTimeout @cutScene2, 500 + if @titleScreen + @titleScreen = false + @cutScene = true + app.game.cutSceneImage = app.images.intro1 + window.setTimeout app.game.cutScene2, 1500 cutScene2: => - @cutSceneImage = app.images.intro2 - window.setTimeout @cutScene3, 500 + app.game.cutSceneImage = app.images.intro2 + window.setTimeout app.game.cutScene3, 2000 cutScene3: => - @cutSceneImage = app.images.intro3 - window.setTimeout @cutScene4, 500 + app.game.cutSceneImage = app.images.intro3 + window.setTimeout app.game.cutScene4, 1500 cutScene4: => - @cutSceneImage = app.images.intro4 - window.setTimeout @cutSceneEnd, 500 + app.game.cutSceneImage = app.images.intro4 + window.setTimeout app.game.cutSceneEnd, 1500 cutSceneEnd: => - @cutScene = false - @intro = true - @startIntro() + app.game.cutScene = false + app.game.intro = true + app.game.startIntro() startIntro: -> @speechbubble.setFix 90, 27 @@ -65,6 +67,10 @@ app.game = app.game.speechbubble.setMouse() render: -> + if @titleScreen + app.layer.drawImage app.images.titlescreen, 0, 0, 20*8, 15*8 + return + if @cutScene app.layer.drawImage @cutSceneImage, 0, 0, 20*8, 15*8 return @@ -125,6 +131,7 @@ app.game = keyup: (event) -> switch event.key + when "enter" then @startCutScene() when "m" then @createMiner() when "e" then @createSolarpanel() when "i" then app.game.hud.showBuildInfo()