Add title screen and cut scene

This commit is contained in:
Aaron Mueller 2014-12-07 19:11:11 +01:00
parent 393af0b9b5
commit c8aedab80a
2 changed files with 23 additions and 16 deletions

View file

@ -5,7 +5,7 @@ app = playground(
smoothing: false, smoothing: false,
create: -> 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 @currentHoveredTile = new Tile
ready: -> ready: ->

View file

@ -15,32 +15,34 @@ app.game =
@hud.start() @hud.start()
@speechbubble.start() @speechbubble.start()
@cutScene = true @cutScene = false
@cutSceneImage = app.images.intro1
@intro = 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: -> startCutScene: ->
window.setTimeout @cutScene2, 500 if @titleScreen
@titleScreen = false
@cutScene = true
app.game.cutSceneImage = app.images.intro1
window.setTimeout app.game.cutScene2, 1500
cutScene2: => cutScene2: =>
@cutSceneImage = app.images.intro2 app.game.cutSceneImage = app.images.intro2
window.setTimeout @cutScene3, 500 window.setTimeout app.game.cutScene3, 2000
cutScene3: => cutScene3: =>
@cutSceneImage = app.images.intro3 app.game.cutSceneImage = app.images.intro3
window.setTimeout @cutScene4, 500 window.setTimeout app.game.cutScene4, 1500
cutScene4: => cutScene4: =>
@cutSceneImage = app.images.intro4 app.game.cutSceneImage = app.images.intro4
window.setTimeout @cutSceneEnd, 500 window.setTimeout app.game.cutSceneEnd, 1500
cutSceneEnd: => cutSceneEnd: =>
@cutScene = false app.game.cutScene = false
@intro = true app.game.intro = true
@startIntro() app.game.startIntro()
startIntro: -> startIntro: ->
@speechbubble.setFix 90, 27 @speechbubble.setFix 90, 27
@ -65,6 +67,10 @@ app.game =
app.game.speechbubble.setMouse() app.game.speechbubble.setMouse()
render: -> render: ->
if @titleScreen
app.layer.drawImage app.images.titlescreen, 0, 0, 20*8, 15*8
return
if @cutScene if @cutScene
app.layer.drawImage @cutSceneImage, 0, 0, 20*8, 15*8 app.layer.drawImage @cutSceneImage, 0, 0, 20*8, 15*8
return return
@ -125,6 +131,7 @@ app.game =
keyup: (event) -> keyup: (event) ->
switch event.key switch event.key
when "enter" then @startCutScene()
when "m" then @createMiner() when "m" then @createMiner()
when "e" then @createSolarpanel() when "e" then @createSolarpanel()
when "i" then app.game.hud.showBuildInfo() when "i" then app.game.hud.showBuildInfo()