Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
368 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class Timer | ||
constructor: ( @events ) -> | ||
@started = false | ||
|
||
setInterval @tick, 1000 | ||
|
||
@counter = new Text() | ||
@counter.textBaseline = "middle" | ||
@counter.textAlign = "center" | ||
@counter.color = "#fff" | ||
@counter.font = "bold 32px 'Cabin', Helvetica,Arial,sans-serif" | ||
@counter.x = 200 | ||
@counter.y = 50 | ||
|
||
canvas = document.getElementById 'timer' | ||
@stage = new Stage canvas | ||
@stage.addChild @counter | ||
|
||
setTime: ( time ) -> | ||
@time = time | ||
|
||
start:() -> | ||
@started = true | ||
|
||
stop:() -> | ||
@started = false | ||
|
||
endOfTime: () -> | ||
@events.trigger "time:out" | ||
|
||
draw: () -> | ||
minutes = Math.floor(@time / 60) | ||
seconds = @time % 60 | ||
|
||
if minutes < 10 | ||
minutes = "0#{minutes}" | ||
|
||
if seconds < 10 | ||
seconds = "0#{seconds}" | ||
|
||
if minutes > 0 | ||
text = "#{ minutes }:#{ seconds }" | ||
else | ||
text = seconds | ||
|
||
@counter.text = text | ||
|
||
tick:() => | ||
if @started | ||
if @time <= 0 | ||
@endOfTime() | ||
else if @time <= 60 | ||
@time-- | ||
@draw() | ||
else | ||
@time-- | ||
@draw() | ||
|
||
@stage.update() | ||
|
||
window.S.Timer = Timer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class='build-costinfo'> | ||
<ul> | ||
{{#each resources}} | ||
{{#with this}} | ||
<li> | ||
<div class='img'> | ||
<img src='/img/{{name}}.png'> | ||
</div> | ||
<div class='desc res-{{name}}'> | ||
{{value}} | ||
</div> | ||
</li> | ||
{{/with}} | ||
{{/each}} | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.