Add score and turns
This commit is contained in:
+15
-1
@@ -6,18 +6,32 @@ RETURN_KEY = 13
|
||||
# Global Data ##########################################################################################################
|
||||
|
||||
$(document).ready ->
|
||||
# configure player input box
|
||||
$input = $("input.entry")
|
||||
$input.on "keydown", ->
|
||||
if event.which isnt RETURN_KEY then return
|
||||
STORY.interpret($input.val())
|
||||
$input.val("")
|
||||
|
||||
# configure the story log display
|
||||
$log = $(".log")
|
||||
$logText = $("p.log-text")
|
||||
|
||||
STORY.log.onChange = (log)->
|
||||
$logText.html(log.content)
|
||||
$log.scrollTop($log[0].scrollHeight)
|
||||
|
||||
# configure the score display
|
||||
$score = $(".score")
|
||||
STORY.player.onChange = (player)->
|
||||
$score.text("score: #{player.score}")
|
||||
STORY.player.onChange(STORY.player)
|
||||
|
||||
# configure the turns display
|
||||
$turns = $(".turns")
|
||||
STORY.onChange = (story)->
|
||||
$turns.text("turns: #{story.turns}")
|
||||
STORY.onChange(STORY)
|
||||
|
||||
# start the story
|
||||
STORY.begin()
|
||||
$input.focus()
|
||||
|
||||
Reference in New Issue
Block a user