@@ -57,7 +57,7 @@ bkcore.hexgl.Gameplay = function(opts)
5757 {
5858 self . raceData . tick ( this . timer . time . elapsed ) ;
5959
60- self . hud . updateTime ( self . timer . getElapsedTime ( ) ) ;
60+ self . hud != null && self . hud . updateTime ( self . timer . getElapsedTime ( ) ) ;
6161 var cp = self . checkPoint ( ) ;
6262
6363 if ( cp == self . track . checkpoints . start && self . previousCheckPoint == self . track . checkpoints . last )
@@ -74,10 +74,10 @@ bkcore.hexgl.Gameplay = function(opts)
7474 else
7575 {
7676 self . lap ++ ;
77- self . hud . updateLap ( self . lap , self . maxLaps ) ;
77+ self . hud != null && self . hud . updateLap ( self . lap , self . maxLaps ) ;
7878
7979 if ( self . lap == self . maxLaps )
80- self . hud . display ( "Final lap" , 0.5 ) ;
80+ self . hud != null && self . hud . display ( "Final lap" , 0.5 ) ;
8181 }
8282 }
8383 else if ( cp != - 1 && cp != self . previousCheckPoint )
@@ -107,7 +107,7 @@ bkcore.hexgl.Gameplay.prototype.simu = function()
107107{
108108 this . lapTimes = [ 92300 , 91250 , 90365 ] ;
109109 this . finishTime = this . lapTimes [ 0 ] + this . lapTimes [ 1 ] + this . lapTimes [ 2 ] ;
110- this . hud . display ( "Finish" ) ;
110+ this . hud != null && this . hud . display ( "Finish" ) ;
111111 this . step = 100 ;
112112 this . result = this . results . FINISH ;
113113 this . shipControls . active = false ;
@@ -128,7 +128,7 @@ bkcore.hexgl.Gameplay.prototype.start = function(opts)
128128 if ( this . mode == 'replay' )
129129 {
130130 this . cameraControls . mode = this . cameraControls . modes . ORBIT ;
131- this . hud . messageOnly = true ;
131+ this . hud != null && this . hud . messageOnly = true ;
132132
133133 try {
134134 var d = localStorage [ 'race-' + this . track . name + '-replay' ] ;
@@ -147,9 +147,12 @@ bkcore.hexgl.Gameplay.prototype.start = function(opts)
147147 this . active = true ;
148148 this . step = 0 ;
149149 this . timer . start ( ) ;
150- this . hud . resetTime ( ) ;
151- this . hud . display ( "Get ready" , 1 ) ;
152- this . hud . updateLap ( this . lap , this . maxLaps ) ;
150+ if ( this . hud != null )
151+ {
152+ this . hud . resetTime ( ) ;
153+ this . hud . display ( "Get ready" , 1 ) ;
154+ this . hud . updateLap ( this . lap , this . maxLaps ) ;
155+ }
153156}
154157
155158bkcore . hexgl . Gameplay . prototype . end = function ( result )
@@ -163,12 +166,12 @@ bkcore.hexgl.Gameplay.prototype.end = function(result)
163166
164167 if ( result == this . results . FINISH )
165168 {
166- this . hud . display ( "Finish" ) ;
169+ this . hud != null && this . hud . display ( "Finish" ) ;
167170 this . step = 100 ;
168171 }
169172 else if ( result == this . results . DESTROYED )
170173 {
171- this . hud . display ( "Destroyed" ) ;
174+ this . hud != null && this . hud . display ( "Destroyed" ) ;
172175 this . step = 100 ;
173176 }
174177}
@@ -181,22 +184,22 @@ bkcore.hexgl.Gameplay.prototype.update = function()
181184
182185 if ( this . step == 0 && this . timer . time . elapsed >= this . countDownDelay + this . startDelay )
183186 {
184- this . hud . display ( "3" ) ;
187+ this . hud != null && this . hud . display ( "3" ) ;
185188 this . step = 1 ;
186189 }
187190 else if ( this . step == 1 && this . timer . time . elapsed >= 2 * this . countDownDelay + this . startDelay )
188191 {
189- this . hud . display ( "2" ) ;
192+ this . hud != null && this . hud . display ( "2" ) ;
190193 this . step = 2 ;
191194 }
192195 else if ( this . step == 2 && this . timer . time . elapsed >= 3 * this . countDownDelay + this . startDelay )
193196 {
194- this . hud . display ( "1" ) ;
197+ this . hud != null && this . hud . display ( "1" ) ;
195198 this . step = 3 ;
196199 }
197200 else if ( this . step == 3 && this . timer . time . elapsed >= 4 * this . countDownDelay + this . startDelay )
198201 {
199- this . hud . display ( "Go" , 0.5 ) ;
202+ this . hud != null && this . hud . display ( "Go" , 0.5 ) ;
200203 this . step = 4 ;
201204 this . timer . start ( ) ;
202205
0 commit comments