Kevin Heinicke 10 gadi atpakaļ
vecāks
revīzija
85e07876c6
3 mainītis faili ar 11 papildinājumiem un 2 dzēšanām
  1. 1 1
      index.html
  2. 2 1
      js/controller.js
  3. 8 0
      js/models/physicist.js

+ 1 - 1
index.html

@@ -42,7 +42,7 @@
       <!-- Collect the nav links, forms, and other content for toggling -->
       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
         <ul class="nav navbar-nav">
-          <li><a href="#" id="a-start-game">Start <span class="sr-only">(current)</span></a></li>
+          <p id="ticker" class="navbar-text" style="position: absolute; width: 60%;"></p>
         </ul>
         <ul class="nav navbar-nav navbar-right">
           <p class="navbar-text">Score: <span id="score"></span></p>

+ 2 - 1
js/controller.js

@@ -7,6 +7,7 @@ var Controller = function(){
 	this.views = [];
 	this.snake = new Snake(this.initial_length);
 	this.canTurn = true;
+    this.facts_shown = {};
 
 	this.counter = 0;
 
@@ -162,7 +163,7 @@ Controller.prototype.tick = function(event){
 Controller.prototype.check_decays = function(){
     for(var pIndex in this.collectibles){
         var p = this.collectibles[pIndex];
-        if(p.decay_time && p.decays && p.decays.length && createjs.Ticker.getTime() > p.decay_time){
+        if(p.half_life && p.decays && p.decays.length && createjs.Ticker.getTime() > p.decay_time){
             var offset = {x: 0, y: 0};
             var counter = 0;
 			var decay = get_random_element_with_probabilities(p.decays);

+ 8 - 0
js/models/physicist.js

@@ -12,4 +12,12 @@ Physicist.prototype.collect = function(collectible) {
 	controller.remove_collectible(collectible);
 	controller.counter += 1;
     controller.update_interface();
+    if(collectible.facts){
+        if(!controller.facts_shown[collectible.type]){
+            $("#ticker").html(collectible.facts[0]);
+            controller.facts_shown[collectible.type] = 1;
+        } else {
+            $("#ticker").html(collectible.facts[controller.facts_shown[collectible.type]++]);
+        }
+    }
 };