J
Jeuiop
Guest
Code:
//STEP EVENT
x = view_xview + 50;
y = view_yview + 260; */
positionFireX = view_xview + 430;
positionFireY = view_yview + 260;
positionMoveX = view_xview + 50;
positionMoveY = view_yview + 260;
mx0 = device_mouse_x(0);
my0 = device_mouse_y(0);
mx1 = device_mouse_x(1);
my1 = device_mouse_y(1);
//--------------POSITION---------------
if(device_mouse_check_button(0, mb_left) or device_mouse_check_button(1, mb_left)){
if( (mx0 < (positionMoveX + 64) and mx0 > (positionMoveX - 64)) and (my0 > (positionMoveY - 64) and my0 < (positionMoveY + 64))){
global.isPressedMove = true;
xCoord0 = mx0;
yCoord0 = my0;
} else if((mx1 < (positionMoveX + 64) and mx1 > (positionMoveX - 64)) and (my1 > (positionMoveY - 64) and my1 < (positionMoveY + 64))){
global.isPressedMove = true;
xCoord0 = mx1;
yCoord0 = my1;
} else {
global.isPressedMove = false;
}
if( (mx0 < (positionFireX + 64) and mx0 > (positionFireX - 64)) and (my0 > (positionFireY - 64) and my0 < (positionFireY + 64))){
global.isPressedFire = true;
xCoord1 = mx0;
yCoord1 = my0;
} else if((mx1 < (positionFireX + 64) and mx1 > (positionFireX - 64)) and (my1 > (positionFireY - 64) and my1 < (positionFireY + 64))){
global.isPressedFire = true;
xCoord1 = mx1;
yCoord1 = my1;
} else {
global.isPressedFire = false;
}
} else {global.isPressedFire = false; global.isPressedMove = false;}
if(global.isPressedMove){
dirMove = point_direction(positionMoveX, positionMoveY, xCoord0, yCoord0);
if(instance_exists(oPlayer)) oPlayer.dir = dirMove;
if(point_distance(positionMoveX, positionMoveY, xCoord0, yCoord0) < 48){
stickX1 = xCoord0;
stickY1 = yCoord0;
} else {
stickX1 = positionMoveX + lengthdir_x(48, dirMove);
stickY1 = positionMoveY + lengthdir_y(48, dirMove);
}
} else {
dirMove = noone;
stickX1 = positionMoveX;
stickY1 = positionMoveY;
global.isPressedMove = false;
}
if(global.isPressedFire){
dirFire = point_direction(positionFireX, positionFireY, xCoord1, yCoord1);
if(instance_exists(oPlayer)) oWeapon.dir = dirFire;
if(point_distance(positionFireX, positionFireY, xCoord1, yCoord1) < 48){
stickX = xCoord1;
stickY = yCoord1;
} else {
stickX = positionFireX + lengthdir_x(48, dirFire);
stickY = positionFireY + lengthdir_y(48, dirFire);
}
} else {
dirFire = noone;
stickX = positionFireX;
stickY = positionFireY;
global.isPressedFire = false;
}
The bug is that when i press both pads at the same time and then release one of them, the other seems to keeps activating and i don't know why. One of the pads is supposed to move the player and other aim to shoot.
Here is the whole code for the pads.