@@ -32,7 +32,7 @@ const float STOMPED_TIME = 1.0f;
32
32
const float TIME_STUNNED = 0 .5f ;
33
33
34
34
const float NORMAL_WALK_SPEED = 80 .0f ;
35
- const float EXPLODING_WALK_SPEED = 160 .0f ;
35
+ const float EXPLODING_WALK_SPEED = 200 .0f ;
36
36
37
37
} // namespace
38
38
@@ -124,7 +124,44 @@ Haywire::active_update(float dt_sec)
124
124
}
125
125
}
126
126
127
- if (is_exploding) {
127
+ if (is_exploding)
128
+ {
129
+ if (on_ground () && std::abs (m_physic.get_velocity_x ()) > 40 .f )
130
+ {
131
+ // jump over 1-tall roadblocks
132
+ Rectf jump_box = get_bbox ();
133
+ jump_box.set_left (m_col.m_bbox .get_left () + (m_dir == Direction::LEFT ? -48 .f : 38 .f ));
134
+ jump_box.set_right (m_col.m_bbox .get_right () + (m_dir == Direction::RIGHT ? 48 .f : -38 .f ));
135
+
136
+ Rectf exception_box = get_bbox ();
137
+ exception_box.set_left (m_col.m_bbox .get_left () + (m_dir == Direction::LEFT ? -48 .f : 38 .f ));
138
+ exception_box.set_right (m_col.m_bbox .get_right () + (m_dir == Direction::RIGHT ? 48 .f : -38 .f ));
139
+ exception_box.set_top (m_col.m_bbox .get_top () - 32 .f );
140
+ exception_box.set_bottom (m_col.m_bbox .get_bottom () - 48 .f );
141
+
142
+ if (!Sector::get ().is_free_of_statics (jump_box) && Sector::get ().is_free_of_statics (exception_box))
143
+ {
144
+ m_physic.set_velocity_y (-325 .f );
145
+ }
146
+ else
147
+ {
148
+ // jump over gaps if Tux isnt below
149
+ Rectf gap_box = get_bbox ();
150
+ gap_box.set_left (m_col.m_bbox .get_left () + (m_dir == Direction::LEFT ? -38 .f : 26 .f ));
151
+ gap_box.set_right (m_col.m_bbox .get_right () + (m_dir == Direction::LEFT ? -26 .f : 38 .f ));
152
+ gap_box.set_top (m_col.m_bbox .get_top ());
153
+ gap_box.set_bottom (m_col.m_bbox .get_bottom () + 28 .f );
154
+
155
+ if (Sector::get ().is_free_of_statics (gap_box)
156
+ && (get_nearest_player ()->get_bbox ().get_bottom () <= m_col.m_bbox .get_bottom ()))
157
+ {
158
+ m_physic.set_velocity_y (-325 .f );
159
+ }
160
+ }
161
+ }
162
+
163
+ // end of pathfinding
164
+
128
165
if (stomped_timer.get_timeleft () < 0 .05f ) {
129
166
set_action ((m_dir == Direction::LEFT) ? " ticking-left" : " ticking-right" , /* loops = */ -1 );
130
167
walk_left_action = " ticking-left" ;
@@ -139,19 +176,20 @@ Haywire::active_update(float dt_sec)
139
176
auto p = get_nearest_player ();
140
177
float target_velocity = 0 .f ;
141
178
142
- if (p && time_stunned == 0 .0f ) {
143
- /* Player is on the right */
144
- if (p->get_pos ().x > get_pos ().x )
145
- target_velocity = walk_speed;
146
- else /* player in on the left */
147
- target_velocity = (-1 .f ) * walk_speed;
179
+ if (stomped_timer.get_timeleft () >= 0 .05f )
180
+ {
181
+ target_velocity = 0 .f ;
182
+ }
183
+ else if (p && time_stunned == 0 .0f )
184
+ {
185
+ /* Player is on the right or left*/
186
+ target_velocity = (p->get_pos ().x > get_pos ().x ) ? walk_speed : (-1 .f ) * walk_speed;
148
187
}
149
188
150
- WalkingBadguy::active_update (dt_sec, target_velocity);
189
+ WalkingBadguy::active_update (dt_sec, target_velocity, 3 . f );
151
190
}
152
- else {
191
+ else
153
192
WalkingBadguy::active_update (dt_sec);
154
- }
155
193
}
156
194
157
195
void
202
240
Haywire::start_exploding ()
203
241
{
204
242
set_walk_speed (EXPLODING_WALK_SPEED);
243
+ max_drop_height = -1 ;
205
244
time_until_explosion = TIME_EXPLOSION;
206
245
is_exploding = true ;
207
246
@@ -223,6 +262,7 @@ Haywire::stop_exploding()
223
262
walk_left_action = " left" ;
224
263
walk_right_action = " right" ;
225
264
set_walk_speed (NORMAL_WALK_SPEED);
265
+ max_drop_height = 16 ;
226
266
time_until_explosion = 0 .0f ;
227
267
is_exploding = false ;
228
268
@@ -255,4 +295,18 @@ void Haywire::play_looping_sounds()
255
295
}
256
296
}
257
297
298
+ HitResponse Haywire::collision_badguy (BadGuy& badguy, const CollisionHit& hit)
299
+ {
300
+ if (is_exploding)
301
+ {
302
+ badguy.kill_fall ();
303
+ return FORCE_MOVE;
304
+ }
305
+ else
306
+ {
307
+ WalkingBadguy::collision_badguy (badguy, hit);
308
+ }
309
+ return ABORT_MOVE;
310
+ }
311
+
258
312
/* EOF */
0 commit comments