Skip to content

Commit

Permalink
Reset camera after screen ends/starts.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Sep 8, 2024
1 parent 634137e commit 564fe2d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ uint16_t CtrMediaNetworkChunkSize = 350;
time_t CtrMediaFrameTimer = 0;
uint16_t CtrMediaSteps;
double CtrMediaVideoFPSRendering;
int CtrMediaCameraInit = 0;

int CtrMediaAudioRate;
uint16_t CtrMediaAudioFormat;
Expand Down Expand Up @@ -935,7 +936,6 @@ void ctr_internal_media_detect_collisions(MediaIMG* m, SDL_Rect r) {

void ctr_internal_media_camera(MediaIMG* m, SDL_Rect* s, SDL_Rect* r, MediaIMG* player) {
static SDL_Rect camera;
static int init_camera = 0;
int border = CtrMediaCamera.w * 0.3;
camera.w = CtrMediaCamera.w;
camera.h = CtrMediaCamera.h;
Expand All @@ -961,13 +961,13 @@ void ctr_internal_media_camera(MediaIMG* m, SDL_Rect* s, SDL_Rect* r, MediaIMG*
if (cpy < top && camera.y > 0) {
camera.y --;
}
if (!init_camera) {
if (!CtrMediaCameraInit) {
camera.x = 0;
camera.y = 0;
if (CtrMediaZoom) {
SDL_RenderSetLogicalSize(CtrMediaRenderer, camera.w, camera.h);
}
init_camera = 1;
CtrMediaCameraInit = 1;
}
if (m == NULL) {
s->x = camera.x;
Expand Down Expand Up @@ -1222,6 +1222,7 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
CtrMediaSelectStart =0;
CtrMediaSelectBegin = 0;
CtrMediaSelectEnd=0;
CtrMediaCameraInit = 0;
//controllableObject = NULL;
focusObject = NULL;
CtrMediaSteps = 0;
Expand Down

0 comments on commit 564fe2d

Please sign in to comment.