tr3
  • Overview
  • Repository
  • Tickets
  • Downloads
  • Credits
  • Statistics
  • Projects

Repository

Increase speed with level number

Parent commits : c25c8a85e801caa63306588d04adeb76a6022b89,
Children commits : 867e3ac9dc291821ff4fe268ab060d4b55c36020,

By Laurent Defert on 2015-06-20 13:31:41
Increase speed with level number

  • Add a level notion that increases speed

Browse content
Difference with parent commit c25c8a85e801caa63306588d04adeb76a6022b89
Files deleted:
tickets/features/levels

Files modified:
js/stage.js
--- 
+++ 
@@ -38,6 +38,7 @@
 
 var SCORE_LABEL = 'Score';
 var GRADE_LABEL = 'Grade';
+var LEVEL_LABEL = 'Level';
 
 // Pause text
 var PAUSE_TEXT = 'Pause\n' +
@@ -66,6 +67,7 @@
     // Score, grade labels
     this.score_label = new PIXI.Text(SCORE_LABEL, getfont());
     this.grade_label = new PIXI.Text(GRADE_LABEL, getfont());
+    this.level_label = new PIXI.Text(LEVEL_LABEL, getfont());
     this.set_labels();
     this.tips = new Tips(this);
 
@@ -119,6 +121,7 @@
     }
 
     this.addChild(this.score_label);
+    this.addChild(this.level_label);
     this.addChild(this.grade_label);
     this.addChild(this.logo);
     this.grid = new Grid(this);
@@ -187,8 +190,17 @@
     }
 };
 
+Stage.prototype.getLevelSpeed = function() {
+    return 1 + (Math.round(this.score / 30) / 10);
+};
+
+Stage.prototype.getLevel = function() {
+    return Math.round(this.score / 30) + 1;
+};
+
 Stage.prototype.set_labels = function() {
     this.score_label.setText(SCORE_LABEL + '\n' + this.score);
+    this.level_label.setText(LEVEL_LABEL + '\n' + this.getLevel());
     var grade = '';
     if (this.srs != null) {
         grade = this.srs.getGrade() + '/' + this.srs.getGradeMax();
@@ -249,7 +261,7 @@
         this.bg.center(this.bg.width / 2, this.bg.height / 2);
     }
 
-    to_resize = [this.score_label, this.grade_label];
+    to_resize = [this.score_label, this.level_label, this.grade_label];
     to_resize.map(function(obj) {
         if (obj) {
             obj.setStyle(getfont());
@@ -258,8 +270,9 @@
     });
 
     var y0 = Grid.getPosition().y;
-    this.score_label.position.y = y0 + Brick.getsize();
-    this.grade_label.position.y = y0 + Brick.getsize() * 3;
+    this.score_label.position.y = y0;
+    this.level_label.position.y = y0 + 1.5 * Brick.getsize();
+    this.grade_label.position.y = y0 + 3 * Brick.getsize();
     this.tips.position.y = y0 + Brick.getsize() * 5;
 
     var sizes = getsizes();
@@ -287,7 +300,7 @@
     if (this.state == GAME_STATE.PLAYING) {
         // Move blocks every seconds
         this.destroy_count = 0;
-        if (Math.floor(now) > Math.floor(last_update)) {
+        if (Math.floor(now * this.getLevelSpeed()) > Math.floor(last_update * this.getLevelSpeed())) {
             this.move_block();
         }
     } else if (this.state == GAME_STATE.FAST_FALL) {

Generated with KisssPM