---
+++
@@ -297,12 +297,7 @@
this.bg_prev.height = this.getsize();
};
-Brick.prototype.showLoseAnim = function() {
- var p = new Particle(this, ANIMS.LOSE);
- this.stage.grid.addChild(p);
-};
-
Brick.prototype.showAnim = function(anym_type) {
var p = new Particle(this, anym_type);
- this.stage.grid.addChild(p);
-};
+ this.stage.addChild(p);
+};
---
+++
@@ -23,7 +23,6 @@
this.stage = stage;
this.grid = [];
this.moving_bricks = [];
- this.particles = [];
for (var y = 0; y < GRID_HEIGHT; y++) {
grid = [];
@@ -158,8 +157,7 @@
return score;
};
-Grid.prototype.resize = function() {
- this.setBG();
+Grid.getPosition = function () {
var left = LABELS_WIDTH * Brick.getsize();
var _top = GRID_TOP * Brick.getsize();
var sizes = getsizes();
@@ -173,8 +171,12 @@
(LABELS_WIDTH + GRID_WIDTH + GRID_RIGHT) *
Brick.getsize()) / 2;
}
-
- this.position = new PIXI.Point(left, _top);
+ return new PIXI.Point(left, _top);
+};
+
+Grid.prototype.resize = function() {
+ this.setBG();
+ this.position = Grid.getPosition();
};
Grid.prototype.hideLettersColor = function(str_idx) {
---
+++
@@ -40,15 +40,15 @@
TRDisplayObjectContainer.call(this);
this.stage = brick.stage;
this.type = anim_type;
- this.position = new PIXI.Point(brick.position.x, brick.position.y);
+ this.position = brick.absPosition();
this.text = new PIXI.Text(decodeStr(this.type.chars[0]), getfont());
this.text.anchor = new PIXI.Point(0.5, 0.5);
- this.text.position = new PIXI.Point(brick.width / 2,
- brick.height / 2);
+ this.text.position = new PIXI.Point(Brick.getsize() / 2,
+ Brick.getsize() / 2);
this.char_no = 0;
this.factor = Math.random();
TRDisplayObjectContainer.prototype.addChild.call(this, this.text);
- this.stage.grid.particles.push(this);
+ this.stage.particles.push(this);
this.init();
}
@@ -72,13 +72,14 @@
}
function chain_anim_cb (particle, val, dt) {
- var y0 = particle.position.y - particle.stage.grid.height / 3;
+ var y0 = particle.position.y - (GRID_HEIGHT * Brick.getsize() / 3);
var y = ((1 - val) * (1 - val)) * (particle.position.y - GRID_WIDTH * Brick.getsize() / 3);
particle.text.position.y = (Brick.getsize() / 2) + y - y0;
particle.text.position.x = (val * (particle.factor - 0.5) * Brick.getsize() * 2)
+ (Brick.getsize() - particle.text.width) / 2;
- if (val > 0.5 && particle.fw === undefined) {
+ if (val > 0.5 && particle.fw === undefined
+ && particle.type.score > 2) {
particle.fw = true;
start_fireworks_cb(particle);
}
@@ -95,9 +96,6 @@
}
function start_fireworks_cb (particle) {
- if (particle.type.score <= 2) {
- return;
- }
anim_type = {
chars: ['*'],
duration: 5,
@@ -112,7 +110,7 @@
- Brick.getsize() / 2,
particle.position.y + particle.text.position.y
- Brick.getsize() / 2);
- particle.stage.grid.addChild(p);
+ particle.stage.addChild(p);
anim_type = {
chars: ['*'],
@@ -128,7 +126,7 @@
- Brick.getsize() / 2,
particle.position.y + particle.text.position.y
- Brick.getsize() / 2);
- particle.stage.grid.addChild(p);
+ particle.stage.addChild(p);
}
Particle.prototype.init = function () {
@@ -151,10 +149,10 @@
if (particle.type.end_callback) {
particle.type.end_callback(particle);
}
- particle.stage.grid.particles.splice(
- particle.stage.grid.particles.indexOf(particle),
+ particle.stage.particles.splice(
+ particle.stage.particles.indexOf(particle),
1);
- particle.stage.grid.removeChild(particle);
+ particle.stage.removeChild(particle);
});
};
@@ -164,3 +162,10 @@
this.char_no = no;
}
};
+
+Particle.prototype.refresh = function(last_update) {
+ if (this.stage.current_screen != SCREENS.GAME) {
+ return;
+ }
+ TRDisplayObjectContainer.prototype.refresh.call(this, last_update);
+};
---
+++
@@ -37,6 +37,7 @@
this.addChild(this.loading);
this.fps = FPS_MIN;
this.timeout = null;
+ this.particles = [];
var _this = this;
loader = new PIXI.JsonLoader(json_config_file);
---
+++
@@ -169,7 +169,6 @@
continue;
}
letters.push(unknown_letters[no]);
- console.log('Adding letter:', this.letters[unknown_letters[no]]);
unknown_letters.splice(no, 1);
}
// Probabilities weights
@@ -191,11 +190,8 @@
weights.sort(function(a, b) {
return b.weight - a.weight;
});
- console.log('weight_total:', weight_total);
- console.log('weights:', weights);
var letter_no = 0;
var rnd = Math.random() * weight_total;
- console.log('rnd:', rnd);
while (weights.length > 1) {
rnd -= weights[0].weight;
if (rnd < 0.0) {
@@ -215,7 +211,6 @@
});
letters = letters.slice(0, BRICK_COLORS_IDX.length);
- console.log('getHilight:', letters);
return letters;
};
---
+++
@@ -299,7 +299,7 @@
console.log('destroy_count', this.destroy_count);
if (this.state == GAME_STATE.DESTROY) {
this.grid.newBlock();
- this.srs.show();
+ //this.srs.show();
this.grid.updateHilight();
this.setState(GAME_STATE.PLAYING);
---
+++
@@ -34,19 +34,23 @@
Tips.prototype.addTip = function(letter) {
var tip = new Tip(this, letter);
- tip.position.y = this.tips.length * Brick.getsize() * 1.1;
- if (this.tips.length >= TIPS_LEN) {
+ this.addChild(tip);
+ tip.position.y = this.tips.length * Math.round(Brick.getsize() * 1.1);
+ for (var i = 0; i < this.tips.length; i++) {
+ tip.position.y -= this.tips[i].offset;
+ }
+
+ this.tips.push(tip);
+
+ if (tip.position.y < TIPS_LEN * Math.round(Brick.getsize() * 1.1)) {
+ tip.showPop();
+ } else {
tip.visible = false;
- } else {
- tip.show();
}
- this.tips.push(tip);
- this.addChild(tip);
- console.log('Adding letter:', this.stage.srs.letters[letter]);
};
Tips.prototype.resize = function () {
- for (var i = 0; i < this.tips.length && i < TIPS_LEN; i++) {
+ for (var i = 0; i < this.tips.length; i++) {
var tip = this.tips[i];
tip.position.y = i * Brick.getsize() * 1.1;
}
@@ -55,12 +59,14 @@
function Tip(tips, letter) {
TRDisplayObjectContainer.call(this);
this.tips = tips;
+ this.timeout = null;
this.arrow = new PIXI.Text('→', getfont());
this.bricks = [new Brick(tips.stage.grid, letter, tips.stage, 1),
new Brick(tips.stage.grid, letter, tips.stage, 1)];
this.bricks[0].setPosition(0, 0);
this.bricks[1].setPosition(2.2, 0);
this.bricks[1].changeText();
+ this.offset = 0;
this.resize();
TRDisplayObjectContainer.prototype.addChild.call(this, this.bricks[0]);
TRDisplayObjectContainer.prototype.addChild.call(this, this.arrow);
@@ -76,6 +82,78 @@
this.arrow.position.y = (Brick.getsize() - this.arrow.height) / 2;
};
+Tip.prototype.showPop = function () {
+ anim_type0 = {
+ chars: ['*'],
+ duration: 5,
+ fade_duration: 2.5,
+ fps: 5,
+ callback: firework_anim_cb,
+ sign: 1
+ };
+ anim_type1 = {
+ chars: ['*'],
+ duration: 5,
+ fade_duration: 2.5,
+ fps: 5,
+ callback: firework_anim_cb,
+ sign: -1
+ };
+ for (var i = 0; i < 2; i++) {
+ this.bricks[i].showAnim(anim_type0);
+ this.bricks[i].showAnim(anim_type1);
+ }
+ this.show();
+}
+
Tip.prototype.show = function () {
+ var _this = this;
+ setTimeout(function() {
+ // Fade-out
+ _this.registerAnimation(0, 1, TIPS_FADE_DT, ANIM_TYPE.LINEAR, function (val) {
+ _this.alpha = 1 - val;
+ }, function () {
+ _this.moveOthers();
+ });
+ }, TIPS_DT * 1000);
+};
+Tip.prototype.showFade = function () {
+ this.alpha = 0.1;
+ this.visible = true;
+ var _this = this;
+ this.registerAnimation(0, 1, TIPS_FADE_DT, ANIM_TYPE.LINEAR, function (val) {
+ _this.alpha = val;
+ }, function () {
+ _this.show();
+ });
+}
+
+Tip.prototype.moveOthers = function () {
+ var _this = this;
+ this.registerAnimation(0, 1, TIPS_MOVE_DT, ANIM_TYPE.LINEAR, function (val) {
+ var offset = Math.round(Brick.getsize() * 1.1 * val);
+ for (var i = _this.tips.tips.indexOf(_this) + 1; i < _this.tips.tips.length; i++) {
+ var tip = _this.tips.tips[i];
+ tip.position.y += _this.offset - offset;
+
+ if (tip.position.y < TIPS_LEN * Math.round(Brick.getsize() * 1.1)
+ && !tip.visible) {
+ tip.showFade();
+ }
+ }
+ _this.offset = offset;
+ }, function () {
+ for (var i = _this.tips.tips.indexOf(_this) + 1; i < _this.tips.tips.length; i++) {
+ var tip = _this.tips.tips[i];
+ tip.position.y += _this.offset - Math.round(Brick.getsize() * 1.1);
+ if (tip.position.y < TIPS_LEN * Math.round(Brick.getsize() * 1.1)
+ && !tip.visible) {
+ tip.showFade();
+ }
+ }
+ _this.offset = Math.round(Brick.getsize() * 1.1);
+ _this.tips.tips.splice(_this.tips.tips.indexOf(_this), 1);
+ _this.tips.removeChild(_this);
+ });
};
---
+++
@@ -41,7 +41,18 @@
this.animations.push([a0, a1, _now, _now + duration, type,
callback, end_callback]);
},
-
+
+ absPosition: function () {
+ var pos = new PIXI.Point(0, 0);
+ var obj = this;
+ while (obj) {
+ pos.x += obj.position.x;
+ pos.y += obj.position.y;
+ obj = obj.parent;
+ }
+ return pos;
+ },
+
refresh: function(last_update) {
var i = 0;
while (true) {
@@ -55,7 +66,11 @@
var end_time = animation[3];
var anim_type = animation[4];
var callback = animation[5];
-
+
+ if (now == start_time) {
+ i++;
+ continue;
+ }
if (anim_type == ANIM_TYPE.LINEAR) {
var a = a0 + ((a1 - a0) /
(end_time - start_time) * (now - start_time));
@@ -78,12 +93,22 @@
a = a < a1 ? a1 : a;
}
- callback(a);
+ try {
+ callback(a);
+ }
+ catch(err) {
+ alert(err.message);
+ }
if (now > end_time) {
var end_callback = animation[6];
if (end_callback != null) {
- end_callback();
+ try {
+ end_callback();
+ }
+ catch(err) {
+ alert(err.message);
+ }
}
this.animations.splice(i, 1);
} else {
Generated with KisssPM