@@ -57,7 +57,7 @@ bkcore.hexgl.Gameplay = function(opts)
57
57
{
58
58
self . raceData . tick ( this . timer . time . elapsed ) ;
59
59
60
- self . hud . updateTime ( self . timer . getElapsedTime ( ) ) ;
60
+ self . hud != null && self . hud . updateTime ( self . timer . getElapsedTime ( ) ) ;
61
61
var cp = self . checkPoint ( ) ;
62
62
63
63
if ( cp == self . track . checkpoints . start && self . previousCheckPoint == self . track . checkpoints . last )
@@ -74,10 +74,10 @@ bkcore.hexgl.Gameplay = function(opts)
74
74
else
75
75
{
76
76
self . lap ++ ;
77
- self . hud . updateLap ( self . lap , self . maxLaps ) ;
77
+ self . hud != null && self . hud . updateLap ( self . lap , self . maxLaps ) ;
78
78
79
79
if ( self . lap == self . maxLaps )
80
- self . hud . display ( "Final lap" , 0.5 ) ;
80
+ self . hud != null && self . hud . display ( "Final lap" , 0.5 ) ;
81
81
}
82
82
}
83
83
else if ( cp != - 1 && cp != self . previousCheckPoint )
@@ -107,7 +107,7 @@ bkcore.hexgl.Gameplay.prototype.simu = function()
107
107
{
108
108
this . lapTimes = [ 92300 , 91250 , 90365 ] ;
109
109
this . finishTime = this . lapTimes [ 0 ] + this . lapTimes [ 1 ] + this . lapTimes [ 2 ] ;
110
- this . hud . display ( "Finish" ) ;
110
+ this . hud != null && this . hud . display ( "Finish" ) ;
111
111
this . step = 100 ;
112
112
this . result = this . results . FINISH ;
113
113
this . shipControls . active = false ;
@@ -128,7 +128,7 @@ bkcore.hexgl.Gameplay.prototype.start = function(opts)
128
128
if ( this . mode == 'replay' )
129
129
{
130
130
this . cameraControls . mode = this . cameraControls . modes . ORBIT ;
131
- this . hud . messageOnly = true ;
131
+ this . hud != null && this . hud . messageOnly = true ;
132
132
133
133
try {
134
134
var d = localStorage [ 'race-' + this . track . name + '-replay' ] ;
@@ -147,9 +147,12 @@ bkcore.hexgl.Gameplay.prototype.start = function(opts)
147
147
this . active = true ;
148
148
this . step = 0 ;
149
149
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
+ }
153
156
}
154
157
155
158
bkcore . hexgl . Gameplay . prototype . end = function ( result )
@@ -163,12 +166,12 @@ bkcore.hexgl.Gameplay.prototype.end = function(result)
163
166
164
167
if ( result == this . results . FINISH )
165
168
{
166
- this . hud . display ( "Finish" ) ;
169
+ this . hud != null && this . hud . display ( "Finish" ) ;
167
170
this . step = 100 ;
168
171
}
169
172
else if ( result == this . results . DESTROYED )
170
173
{
171
- this . hud . display ( "Destroyed" ) ;
174
+ this . hud != null && this . hud . display ( "Destroyed" ) ;
172
175
this . step = 100 ;
173
176
}
174
177
}
@@ -181,22 +184,22 @@ bkcore.hexgl.Gameplay.prototype.update = function()
181
184
182
185
if ( this . step == 0 && this . timer . time . elapsed >= this . countDownDelay + this . startDelay )
183
186
{
184
- this . hud . display ( "3" ) ;
187
+ this . hud != null && this . hud . display ( "3" ) ;
185
188
this . step = 1 ;
186
189
}
187
190
else if ( this . step == 1 && this . timer . time . elapsed >= 2 * this . countDownDelay + this . startDelay )
188
191
{
189
- this . hud . display ( "2" ) ;
192
+ this . hud != null && this . hud . display ( "2" ) ;
190
193
this . step = 2 ;
191
194
}
192
195
else if ( this . step == 2 && this . timer . time . elapsed >= 3 * this . countDownDelay + this . startDelay )
193
196
{
194
- this . hud . display ( "1" ) ;
197
+ this . hud != null && this . hud . display ( "1" ) ;
195
198
this . step = 3 ;
196
199
}
197
200
else if ( this . step == 3 && this . timer . time . elapsed >= 4 * this . countDownDelay + this . startDelay )
198
201
{
199
- this . hud . display ( "Go" , 0.5 ) ;
202
+ this . hud != null && this . hud . display ( "Go" , 0.5 ) ;
200
203
this . step = 4 ;
201
204
this . timer . start ( ) ;
202
205
0 commit comments