Skip to content

Commit 6d74a8c

Browse files
committed
commit dist
1 parent 6df9492 commit 6d74a8c

File tree

3 files changed

+71
-27
lines changed

3 files changed

+71
-27
lines changed

dist/game.js

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -951,22 +951,24 @@ Weather.prototype = {
951951
Weather.dt = now - G.gameStartTime;
952952

953953
sunMoon.update();
954-
cloud.update();
955-
956-
// console.log(M.ceil(Weather.dt / 1000))
957-
if (!this.canRain && M.ceil(Weather.dt / 1000) % 16 === 0) {
958-
this.canRain = true;
959-
this.isRaining = true;
960-
} else if (M.ceil(Weather.dt / 1000) % 33 === 0) {
961-
this.canRain = false;
962-
this.isRaining = false;
963-
}
954+
if (!G.isMobile()) {
955+
cloud.update();
956+
957+
// console.log(M.ceil(Weather.dt / 1000))
958+
if (!this.canRain && M.ceil(Weather.dt / 1000) % 16 === 0) {
959+
this.canRain = true;
960+
this.isRaining = true;
961+
} else if (M.ceil(Weather.dt / 1000) % 33 === 0) {
962+
this.canRain = false;
963+
this.isRaining = false;
964+
}
964965

965-
if (this.canRain && this.isRaining) {
966-
rain.update();
967-
}
966+
if (this.canRain && this.isRaining) {
967+
rain.update();
968+
}
968969

969-
wind.update();
970+
wind.update();
971+
}
970972
},
971973
init: function () {
972974
cloud = new Cloud();
@@ -1188,6 +1190,9 @@ var flameBack = new function() {
11881190
width = (this.canvas.width + 30) / scale;
11891191
height = P.fireOffset / scale;
11901192

1193+
width = Math.ceil(width);
1194+
height = Math.ceil(height);
1195+
11911196
colorMap = Array(width * height);
11921197

11931198
for(var i = 0; i < colorMap.length; i++)
@@ -1224,9 +1229,20 @@ var flameBack = new function() {
12241229

12251230
// main render loop
12261231
this.update = function() {
1227-
smooth();
1228-
draw();
1229-
fan = utils.getRandomInt(0, 6);
1232+
if (!G.isMobile()) {
1233+
smooth();
1234+
draw();
1235+
fan = utils.getRandomInt(0, 6);
1236+
} else {
1237+
var grd = ctx.createLinearGradient(0, CC.h - P.fireOffset , 0, G.can.height);
1238+
grd.addColorStop(0, 'rgba(255, 0, 0, ' + utils.getRandomInt(8, 10)/10 + ')');
1239+
grd.addColorStop(0.7, 'rgba(255, 165, 0, ' + utils.getRandomInt(8, 10)/10 + ')');
1240+
grd.addColorStop(0.9, 'rgba(255, 255, 0, ' + utils.getRandomInt(8, 10)/10 + ')');
1241+
sv();
1242+
fs(grd);
1243+
fr(0, CC.h - P.fireOffset, G.can.width, P.fireOffset)
1244+
rs();
1245+
}
12301246
};
12311247

12321248
var smooth = function() {
@@ -1577,8 +1593,12 @@ function Tree(config) {
15771593
T.color = '#a77b44';
15781594
this.add();
15791595
if (!config.isNoFlame) {
1580-
this.flame = smoky;
1581-
this.flame.addEntity(Flame);
1596+
if (G.isMobile()) {
1597+
this.flame = true;
1598+
} else {
1599+
this.flame = smoky;
1600+
this.flame.addEntity(Flame);
1601+
}
15821602
}
15831603
return T;
15841604
}
@@ -1689,9 +1709,29 @@ Tree.prototype = {
16891709
el(ctx, x, y - 4, width, 10, '#6b4e2a');
16901710

16911711
if (treeInstance.flame) {
1692-
treeInstance.flame.update(x, y, width);
1712+
if (G.isMobile()) {
1713+
T.addCircle(x, y, width);
1714+
} else {
1715+
treeInstance.flame.update(x, y, width);
1716+
}
16931717
}
16941718
},
1719+
addCircle: function (x, y, width) {
1720+
bp();
1721+
ar(x + (width/2), y, width/2, 0, Math.PI*2, false);
1722+
fs('rgba(255, 0, 0, 0.4)');
1723+
fl();
1724+
1725+
bp();
1726+
ar(x + (width/2), y, width/3, 0, Math.PI*2, false);
1727+
fs('rgba(255, 165, 0, 0.4)');
1728+
fl();
1729+
1730+
bp();
1731+
ar(x + (width/2), y, width/6, 0, Math.PI*2, false);
1732+
fs('rgba(255, 255, 0, ' + utils.getRandomInt(0.3, 0.5)/10 + ')');
1733+
fl();
1734+
},
16951735
preCompute: function () {
16961736
T.lw = blw + bw + (bw === 0 ? 0 : utils.getRandomInt(T.minDist, T.maxDist));
16971737
blw = T.lw;
@@ -1850,7 +1890,8 @@ Game.prototype = {
18501890
fs(G.backgroundColor);
18511891
fr(0, 0, CC.w, CC.h);
18521892

1853-
if (G.speed > 1.6 &&
1893+
var speedIncFactor = G.isMobile() ? 1.1 : 1.6;
1894+
if (G.speed >= speedIncFactor &&
18541895
utils.getRandomInt(0, 10) === 10
18551896
) {
18561897
G.showNoisyScreen();
@@ -2011,11 +2052,13 @@ Game.prototype = {
20112052
}
20122053
},
20132054
keyDown: function(e) {
2014-
// 32 is space
2015-
/*if (e.keyCode === 32 && !G.isInProgress) {
2016-
G.restart();
2055+
// 13 is enter
2056+
if ((e.keyCode === 13 || e.keyCode === 32) && G.menu) {
2057+
G.menu = null;
2058+
G.restart();
2059+
SU.play('playGame');
20172060
return;
2018-
}*/
2061+
}
20192062
if (!G.isInProgress) {
20202063
return;
20212064
}

0 commit comments

Comments
 (0)