R
Rosepike
Guest
Hello!
I'm only new to game maker, and when i say new, i mean I've been using the software for less than a month.
Anyway, I'm having problem with trying to get my player to shoot with the left mouse button, while also moving.
For some reason the left click button wasn't working for me so i replaced it with the "E" key instead. However, the player cannot move and shoot at the same time which is really annoying.
Heres my code;
///Movement
//Left
if (keyboard_check(ord("A"))) && (place_free(x - Speed,y))
{ sprite_index = s_player_right
image_speed = 0.2
x -= Speed
image_xscale = -1
}
//Right
if (keyboard_check(ord("D"))) && (place_free(x + Speed,y))
{ sprite_index = s_player_right
image_speed = 0.2
x += Speed
image_xscale = 1
}
//Idle
if (!keyboard_check(ord("A"))) && (!keyboard_check(ord("D")))
{ image_speed = 0
image_index = 1
}
//shoot Left
if (keyboard_check(ord("E"))) && (keyboard_check(ord("A"))) && (place_free(x - Speed,y)) {
sprite_index = spr_player_shoot;
image_speed = 0.2
x -= Speed
image_xscale = -1
global.facing = 1
instance_create(x,y,obj_shoot)
}
//Shoot Right
if (keyboard_check(ord("E"))) && (keyboard_check(ord("D"))) && (place_free(x + Speed,y)) {
sprite_index = spr_player_shoot;
image_speed = 0.2
x -= Speed
image_xscale = 1
global.facing = 0
instance_create(x,y,obj_shoot)
}
I'm only new to game maker, and when i say new, i mean I've been using the software for less than a month.
Anyway, I'm having problem with trying to get my player to shoot with the left mouse button, while also moving.
For some reason the left click button wasn't working for me so i replaced it with the "E" key instead. However, the player cannot move and shoot at the same time which is really annoying.
Heres my code;
///Movement
//Left
if (keyboard_check(ord("A"))) && (place_free(x - Speed,y))
{ sprite_index = s_player_right
image_speed = 0.2
x -= Speed
image_xscale = -1
}
//Right
if (keyboard_check(ord("D"))) && (place_free(x + Speed,y))
{ sprite_index = s_player_right
image_speed = 0.2
x += Speed
image_xscale = 1
}
//Idle
if (!keyboard_check(ord("A"))) && (!keyboard_check(ord("D")))
{ image_speed = 0
image_index = 1
}
//shoot Left
if (keyboard_check(ord("E"))) && (keyboard_check(ord("A"))) && (place_free(x - Speed,y)) {
sprite_index = spr_player_shoot;
image_speed = 0.2
x -= Speed
image_xscale = -1
global.facing = 1
instance_create(x,y,obj_shoot)
}
//Shoot Right
if (keyboard_check(ord("E"))) && (keyboard_check(ord("D"))) && (place_free(x + Speed,y)) {
sprite_index = spr_player_shoot;
image_speed = 0.2
x -= Speed
image_xscale = 1
global.facing = 0
instance_create(x,y,obj_shoot)
}