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,
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: ->

View file

@ -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()