Skip to content

Commit

Permalink
Do not allow player to cross window borders.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Sep 11, 2024
1 parent 564fe2d commit d9f27f4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,19 @@ void ctr_internal_media_image_calculate_motion(MediaIMG* m) {
m->x += dt * CtrMediaContactSurface->mov * cos(CtrMediaContactSurface->dir * M_PI / 180);
m->y -= dt * CtrMediaContactSurface->mov * sin(CtrMediaContactSurface->dir * M_PI / 180);
}
if (m == player && CtrMediaControlMode < 5) {
int xmin = 0;
int ymin = 0;
int xmax = windowWidth - (m->w/m->anims);
int ymax = windowHeight - (m->h);
if (m->x > xmax) m->x = xmax;
if (m->y > ymax) m->y = ymax;
if (m->x < xmin) m->x = xmin;
if (CtrMediaControlMode != 1 || !CtrMediaJump) {
// in platform games, players are allowed to jump 'out of vision' at the top
if (m->y < ymin) m->y = ymin;
}
}
}
}

Expand Down

0 comments on commit d9f27f4

Please sign in to comment.