@@ -951,22 +951,24 @@ Weather.prototype = {
951
951
Weather . dt = now - G . gameStartTime ;
952
952
953
953
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
+ }
964
965
965
- if ( this . canRain && this . isRaining ) {
966
- rain . update ( ) ;
967
- }
966
+ if ( this . canRain && this . isRaining ) {
967
+ rain . update ( ) ;
968
+ }
968
969
969
- wind . update ( ) ;
970
+ wind . update ( ) ;
971
+ }
970
972
} ,
971
973
init : function ( ) {
972
974
cloud = new Cloud ( ) ;
@@ -1188,6 +1190,9 @@ var flameBack = new function() {
1188
1190
width = ( this . canvas . width + 30 ) / scale ;
1189
1191
height = P . fireOffset / scale ;
1190
1192
1193
+ width = Math . ceil ( width ) ;
1194
+ height = Math . ceil ( height ) ;
1195
+
1191
1196
colorMap = Array ( width * height ) ;
1192
1197
1193
1198
for ( var i = 0 ; i < colorMap . length ; i ++ )
@@ -1224,9 +1229,20 @@ var flameBack = new function() {
1224
1229
1225
1230
// main render loop
1226
1231
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
+ }
1230
1246
} ;
1231
1247
1232
1248
var smooth = function ( ) {
@@ -1577,8 +1593,12 @@ function Tree(config) {
1577
1593
T . color = '#a77b44' ;
1578
1594
this . add ( ) ;
1579
1595
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
+ }
1582
1602
}
1583
1603
return T ;
1584
1604
}
@@ -1689,9 +1709,29 @@ Tree.prototype = {
1689
1709
el ( ctx , x , y - 4 , width , 10 , '#6b4e2a' ) ;
1690
1710
1691
1711
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
+ }
1693
1717
}
1694
1718
} ,
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
+ } ,
1695
1735
preCompute : function ( ) {
1696
1736
T . lw = blw + bw + ( bw === 0 ? 0 : utils . getRandomInt ( T . minDist , T . maxDist ) ) ;
1697
1737
blw = T . lw ;
@@ -1850,7 +1890,8 @@ Game.prototype = {
1850
1890
fs ( G . backgroundColor ) ;
1851
1891
fr ( 0 , 0 , CC . w , CC . h ) ;
1852
1892
1853
- if ( G . speed > 1.6 &&
1893
+ var speedIncFactor = G . isMobile ( ) ? 1.1 : 1.6 ;
1894
+ if ( G . speed >= speedIncFactor &&
1854
1895
utils . getRandomInt ( 0 , 10 ) === 10
1855
1896
) {
1856
1897
G . showNoisyScreen ( ) ;
@@ -2011,11 +2052,13 @@ Game.prototype = {
2011
2052
}
2012
2053
} ,
2013
2054
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' ) ;
2017
2060
return ;
2018
- }*/
2061
+ }
2019
2062
if ( ! G . isInProgress ) {
2020
2063
return ;
2021
2064
}
0 commit comments