Skip to content

Commit babcbdf

Browse files
committed
Add nodirani.
1 parent 5f47f10 commit babcbdf

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

plugins/media/media.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct MediaIMG {
117117
char bounce;
118118
char fixed;
119119
char ghost;
120+
char nodirani;
120121
};
121122
typedef struct MediaIMG MediaIMG;
122123

@@ -866,7 +867,8 @@ void ctr_internal_media_detect_collisions(MediaIMG* m, SDL_Rect r) {
866867
collider->next = NULL;
867868
for (int j = 0; j < IMGCount; j++) {
868869
MediaIMG* m2 = &mediaIMGs[j];
869-
if (m2 == m || m->fixed || m2->fixed) continue;
870+
//skip if image is same, fixed or gc'ed (ref)
871+
if (m2 == m || m->fixed || m2->fixed || m->ref == NULL || m2->ref == NULL) continue;
870872
int h,w,w2;
871873
h = (int) m->h;
872874
w = (int) m->w / (m->anims ? m->anims : 1);
@@ -968,7 +970,7 @@ void ctr_internal_media_render_image(MediaIMG* m, SDL_Rect r, SDL_Rect s, MediaI
968970
if (!r.w || !r.h) {
969971
return;
970972
}
971-
if (m->dir > -1 && !m->solid && CtrMediaControlMode == 1) {
973+
if (m->dir > -1 && !m->solid && !m->nodirani && CtrMediaControlMode == 1) {
972974
if (m->gravity) {
973975
int xdir = m->dir;
974976
if (m->gravity < 1) {
@@ -990,7 +992,7 @@ void ctr_internal_media_render_image(MediaIMG* m, SDL_Rect r, SDL_Rect s, MediaI
990992
SDL_RenderCopyEx(CtrMediaRenderer, m->texture, &s, &r, (m->dir == -1 ? 0 : m->dir), NULL, (m->dir == 90 || m->dir == 270) ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE);
991993
}
992994
}
993-
else if (CtrMediaControlMode == 4) {
995+
else if (CtrMediaControlMode == 4 && !m->solid && !m->nodirani) {
994996
/* radius style (2D top-down racing), in this case adjust direction to exact degrees */
995997
SDL_RenderCopyEx(CtrMediaRenderer, m->texture, &s, &r, 360-(m->dir == -1 ? 0 : m->dir), NULL, SDL_FLIP_NONE);
996998
}
@@ -2231,6 +2233,7 @@ ctr_object* ctr_img_new(ctr_object* myself, ctr_argument* argumentList) {
22312233
mediaImage->mov = 0;
22322234
mediaImage->anims = 1;
22332235
mediaImage->animspeed = 5;
2236+
mediaImage->nodirani = 0;
22342237
mediaImage->editable = 0;
22352238
mediaImage->text = NULL;
22362239
mediaImage->paddingx = 0;
@@ -2309,6 +2312,12 @@ ctr_object* ctr_img_ghost_set(ctr_object* myself, ctr_argument* argumentList) {
23092312
return myself;
23102313
}
23112314

2315+
ctr_object* ctr_media_nodirani(ctr_object* myself, ctr_argument* argumentList) {
2316+
MediaIMG* mediaImage = ctr_internal_get_image_from_object(myself);
2317+
mediaImage->nodirani = ctr_internal_cast2bool( argumentList->object )->value.bvalue;
2318+
return myself;
2319+
}
2320+
23122321
/**
23132322
* @def
23142323
* [ Image ] controllable: [ Number ]
@@ -4373,6 +4382,7 @@ void begin(){
43734382
ctr_internal_create_func(imageObject, ctr_build_string_from_cstring( "static:" ), &ctr_img_fixed_set );
43744383
ctr_internal_create_func(imageObject, ctr_build_string_from_cstring( "ghost:" ), &ctr_img_ghost_set );
43754384
ctr_internal_create_func(imageObject, ctr_build_string_from_cstring( "aspeed:" ), &ctr_media_anim_speed );
4385+
ctr_internal_create_func(imageObject, ctr_build_string_from_cstring( "nodirani:" ), &ctr_media_nodirani );
43764386
audioObject = ctr_audio_new(CtrStdObject, NULL);
43774387
audioObject->link = CtrStdObject;
43784388
ctr_internal_create_func(audioObject, ctr_build_string_from_cstring( CTR_DICT_NEW ), &ctr_audio_new );

0 commit comments

Comments
 (0)