Skip to content

Commit 69536fb

Browse files
committed
Add on-screen controls for mobile.
1 parent a9356e2 commit 69536fb

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

plugins/media/media.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,9 @@ void ctr_internal_media_image_calculate_motion(MediaIMG* m) {
10571057
m->gspeed = 0;
10581058
}
10591059
if (m->mov > 0 && m->dir > -1) {
1060+
if (m->x != m->tx)
10601061
m->x += dt * m->mov * cos(m->dir * M_PI / 180);
1062+
if (m->y != m->ty)
10611063
m->y -= dt * m->mov * sin(m->dir * M_PI / 180);
10621064
// an image reaches its destination if the destination falls between
10631065
// this step and the previous one (i.e. tx is between ox and x and ty
@@ -1404,18 +1406,22 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
14041406
if (ctr_internal_media_mouse_down(event)) return CtrStdFlow;
14051407
break;
14061408
case SDL_FINGERDOWN:
1407-
if (event.tfinger.x * windowWidth > player->x) {
1408-
ctr_internal_media_keydown_right(&dir);
1409-
}
1410-
else if (event.tfinger.x * windowWidth < player->x - (player->w/player->anims)) {
1411-
ctr_internal_media_keydown_left(&dir);
1412-
}
1413-
if (event.tfinger.y * windowHeight > player->y - player->h) {
1414-
ctr_internal_media_keydown_down(&dir, &c4speed);
1415-
}
1416-
else if (event.tfinger.y * windowHeight < player->y - player->h) {
1417-
ctr_internal_media_keydown_up(&dir, &c4speed);
1409+
if (event.tfinger.y > 0.75) {
1410+
if (event.tfinger.x < 0.1) {
1411+
ctr_internal_media_keydown_left(&dir);
1412+
}
1413+
if (event.tfinger.x > 0.1 && event.tfinger.x < 0.2) {
1414+
ctr_internal_media_keydown_right(&dir);
1415+
}
14181416
}
1417+
if (event.tfinger.x > 0.9) {
1418+
if (event.tfinger.y > 0.8) {
1419+
ctr_internal_media_keydown_down(&dir, &c4speed);
1420+
}
1421+
if (event.tfinger.y < 0.8 && event.tfinger.y > 0.5) {
1422+
ctr_internal_media_keydown_up(&dir, &c4speed);
1423+
}
1424+
}
14191425
break;
14201426
case SDL_FINGERUP:
14211427
ctr_internal_media_keyup_right(&dir, &c4speed);
@@ -3101,7 +3107,7 @@ void ctr_internal_media_init() {
31013107
#ifdef FULLSCREEN
31023108
CtrMediaWindow = SDL_CreateWindow("Citrine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN);
31033109
#else
3104-
CtrMediaWindow = SDL_CreateWindow("Citrine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_OPENGL);
3110+
CtrMediaWindow = SDL_CreateWindow("Citrine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN_DESKTOP);
31053111
#endif
31063112
if (CtrMediaWindow == NULL) ctr_internal_media_fatalerror("Unable to create window", SDL_GetError());
31073113
CtrMediaFlagSoftwareVSync = 0;

0 commit comments

Comments
 (0)