@@ -150,7 +150,7 @@ static void platform_new(void) {
150
150
distance -= SCROLL_STEP;
151
151
display_background ();
152
152
display_platform (platformFuture, WHITE);
153
- display_hero (0 , distance + bridge , HERO_LEVEL, WHITE);
153
+ display_hero (0 , platform_end (data-> platformNext ) - HERO_OFFSET , HERO_LEVEL, WHITE);
154
154
gr->display ();
155
155
}
156
156
@@ -192,10 +192,15 @@ static void hero_score(int8_t up) {
192
192
193
193
194
194
static int8_t hero_walk (int8_t from, int8_t to) {
195
- int8_t bridge_end;
195
+ const int8_t bridge_end = platform_end (data->platformCurr ) + bridge;
196
+ const int8_t bridge_over = bridge_end - 1 > platform_end (data->platformNext );
196
197
int8_t hero_state = 0 ;
197
198
int8_t claim_bonus = 0 ;
198
199
int8_t i = from;
200
+
201
+ if (! bridge_over) {
202
+ to = min (to, platform_end (data->platformNext ) - HERO_OFFSET);
203
+ }
199
204
while (i < to) {
200
205
if (!gr->nextFrame ()) {
201
206
continue ;
@@ -209,13 +214,9 @@ static int8_t hero_walk(int8_t from, int8_t to) {
209
214
gr->display ();
210
215
211
216
// Game over?
212
- bridge_end = platform_end (data->platformCurr ) + bridge;
213
217
// TODO: simplify this condition
214
- if ((i + HERO_OFFSET >= bridge_end &&
215
- (data->platformNext .x >= bridge_end ||
216
- bridge_end - 1 > platform_end (data->platformNext ))) ||
217
- (hero_state &&
218
- i + HERO_OFFSET + HERO_OFFSET > data->platformNext .x )) {
218
+ if ((i + HERO_OFFSET >= bridge_end && (data->platformNext .x >= bridge_end || bridge_over)) ||
219
+ (hero_state && i + HERO_OFFSET + HERO_OFFSET > data->platformNext .x )) {
219
220
data->gameOn = 0 ;
220
221
hero_fall (i + HERO_OFFSET + (hero_state ? -1 : 1 ),
221
222
HERO_LEVEL - (hero_state ? 0 : HERO_HEIGHT));
0 commit comments