Dupletor
Member
This script worked for the past 4 months with no problem.
Now for no reason it stopped working if x_scale == 0.5 or y_scale == 0.5, but still works if x_scale == 0.50001 and y_scale == 0.50001, with same properties it always had, working.
Also doesn't work if x_scale < 0.5 or y_scale < 0.5;
It's an old buttons collision code, I was very early in GM before I made this. I just didn't replace it because it worked well, but now I'm thinking of building a new one because of that.
Any idea why it doesn't work if x_scale == 0.5 or y_scale == 0.5 though? I updated GameMaker today and never had a problem with this specific value, maybe something changed?
(By the way, it is working, I just wanted to understand the singularity)
Now for no reason it stopped working if x_scale == 0.5 or y_scale == 0.5, but still works if x_scale == 0.50001 and y_scale == 0.50001, with same properties it always had, working.
Also doesn't work if x_scale < 0.5 or y_scale < 0.5;
It's an old buttons collision code, I was very early in GM before I made this. I just didn't replace it because it worked well, but now I'm thinking of building a new one because of that.
Any idea why it doesn't work if x_scale == 0.5 or y_scale == 0.5 though? I updated GameMaker today and never had a problem with this specific value, maybe something changed?
(By the way, it is working, I just wanted to understand the singularity)
Code:
button1 = argument0;
button2 = argument1;
if(button1.x == button2.x && button1.y == button2.y){
button1.x++;
button2.x--;
}
if((button1.x + sprite_get_width(button1.sprite_index)/2 * button1.image_xscale >= button2.x - sprite_get_width(button2.sprite_index)/2 * button2.image_xscale &&
button1.x - sprite_get_width(button1.sprite_index)/2 * button1.image_xscale <= button2.x + sprite_get_width(button2.sprite_index)/2) * button2.image_xscale &&
(button1.y + sprite_get_height(button1.sprite_index)/2 * button1.image_yscale >= button2.y - sprite_get_height(button2.sprite_index)/2 * button2.image_yscale &&
button1.y - sprite_get_height(button1.sprite_index)/2 * button1.image_yscale <= button2.y + sprite_get_height(button2.sprite_index)/2 * button2.image_yscale)
){
if(button1.x - sprite_get_width(button1.sprite_index)/2 * button1.image_xscale >= button2.x - sprite_get_width(button2.sprite_index)/2 * button2.image_xscale) {
if(button1.x - sprite_get_width(button1.sprite_index)/2 * button1.image_xscale <= button2.x + sprite_get_width(button2.sprite_index)/2 * button2.image_xscale) {
button1.x++;
button2.x--;
}
} else if(button1.x + sprite_get_width(button1.sprite_index)/2 * button1.image_xscale >= button2.x - sprite_get_width(button2.sprite_index)/2 * button2.image_xscale) {
button1.x--;
button2.x++;
}
if(button1.y - sprite_get_height(button2.sprite_index)/2 * button1.image_yscale >= button2.y - sprite_get_height(button2.sprite_index)/2 * button2.image_yscale) {
if(button1.y - sprite_get_height(button1.sprite_index)/2 * button1.image_yscale <= button2.y + sprite_get_height(button2.sprite_index)/2 * button2.image_yscale) {
button1.y++;
button2.y--;
}
} else if(button1.y + sprite_get_height(button1.sprite_index)/2 * button1.image_yscale >= button2.y - sprite_get_height(button2.sprite_index)/2 * button2.image_yscale) {
button1.y--;
button2.y++;
}
}
Last edited: