R
RisingKane
Guest
Hello everyone!
I'm facing some trouble with my codes lately, and I'd like to share it with you and see if you guys can help me.
- In the code above, the bt_mov variables receive the x and y values of the 4 instances of the button object on screen;
- I have 4 positions in my screen, and its corresponding position in my array vec_exe:
- If none of the buttons are set in some of the 4 pre-determined positions, the 4 positions of 'vec_exe' are set to 0.
- That code is a step event, from an object called 'obj_area_cod2'
Then, in the code above (thanks to NazGhuL, who helped me), I try to display a message containing the content of all the positions of the vec_exe array. But the problem is that, sometimes it shows the correct string, and sometimes it doesn't, especially when there are two or more elements in the array at the same time. Sorry if it's mess and if I wasn't clear enough.
Anyone knows what could be happening? Thanks!
I'm facing some trouble with my codes lately, and I'd like to share it with you and see if you guys can help me.
Code:
var bt_mov_up_x = inst_01E615EC.x, bt_mov_up_y = inst_01E615EC.y;
var bt_mov_down_x = inst_956A28E7.x, bt_mov_down_y = inst_956A28E7.y;
var bt_mov_left_x = inst_719C077E.x, bt_mov_left_y = inst_719C077E.y;
var bt_mov_right_x = inst_2D859A0E.x, bt_mov_right_y = inst_2D859A0E.y;
//UP BUTTON
//Position [1]
if (bt_mov_up_x == 384 && bt_mov_up_y == 256 ) {
vec_exe[0] = "mov_up";
empty = false;
}
//Position [2]
else if (bt_mov_up_x == 384 && bt_mov_up_y == 288 ) {
vec_exe[1] = "mov_up";
empty = false;
}
//Position [3]
else if (bt_mov_up_x == 384 && bt_mov_up_y == 320 ) {
vec_exe[2] = "mov_up";
empty = false;
}
//Position [4]
else if (bt_mov_up_x == 384 && bt_mov_up_y == 352 ) {
vec_exe[3] = "mov_up";
empty = false;
}
//DOWN BUTTON
//Position [1]
else if (bt_mov_down_x == 384 && bt_mov_down_y == 256 ) {
vec_exe[0] = "mov_down";
empty = false;
}
//Position [2]
else if (bt_mov_down_x == 384 && bt_mov_down_y == 288 ) {
vec_exe[1] = "mov_down";
empty = false;
}
//Position [3]
else if (bt_mov_down_x == 384 && bt_mov_down_y == 320 ) {
vec_exe[2] = "mov_down";
empty = false;
}
//Position [4]
else if (bt_mov_down_x == 384 && bt_mov_down_y == 352 ) {
vec_exe[3] = "mov_down";
empty = false;
}
//LEFT BUTTON
//Position [1]
else if (bt_mov_left_x == 384 && bt_mov_left_y == 256 ) {
vec_exe[0] = "mov_left";
empty = false;
}
//Position [2]
else if (bt_mov_left_x == 384 && bt_mov_left_y == 288 ) {
vec_exe[1] = "mov_left";
empty = false;
}
//Position [3]
else if (bt_mov_left_x == 384 && bt_mov_left_y == 320 ) {
vec_exe[2] = "mov_left";
empty = false;
}
//Position [4]
else if (bt_mov_left_x == 384 && bt_mov_left_y == 352 ) {
vec_exe[3] = "mov_left";
empty = false;
}
//RIGHT BUTTON
//Position [1]
else if (bt_mov_right_x == 384 && bt_mov_right_y == 256 ) {
vec_exe[0] = "mov_right";
empty = false;
}
//Position [2]
else if (bt_mov_right_x == 384 && bt_mov_right_y == 288 ) {
vec_exe[1] = "mov_right";
empty = false;
}
//Position [3]
else if (bt_mov_right_x == 384 && bt_mov_right_y == 320 ) {
vec_exe[2] = "mov_right";
empty = false;
}
//Position [4]
else if (bt_mov_right_x == 384 && bt_mov_right_y == 352 ) {
vec_exe[3] = "mov_right";
empty = false;
}
else {
vec_exe[0] = 0;
vec_exe[1] = 0;
vec_exe[2] = 0;
vec_exe[3] = 0;
empty = true;
}
- I have 4 positions in my screen, and its corresponding position in my array vec_exe:
[0] 384×256
[1] 384×288
[2] 384×320
[3] 384×352
- Then, through checking if the position of the buttons equals to one of the positions above, a string value is assigned to the corresponding position of vec_exe.[1] 384×288
[2] 384×320
[3] 384×352
- If none of the buttons are set in some of the 4 pre-determined positions, the 4 positions of 'vec_exe' are set to 0.
- That code is a step event, from an object called 'obj_area_cod2'
Code:
//Starts the game
var msg = "";
with (obj_area_cod2) {
for (i = 0; i <= array_length_1d(vec_exe) - 1; i += 1) {
msg += string((vec_exe[i])) + "#";
}
}
show_message(msg);
Anyone knows what could be happening? Thanks!