pixeltroid
Member
Okay so I have (or used to have) a bunch of code that gets my player to walk, jump, crouch, point up and shoot in all those states.
Yesterday, I decided to have player shoot continuously by holding down key press. Now when I'm running and holding down the shoot button, the player shoots continuously, but doesn't move forward. He just remains in the same spot while playing the walking sprite (spr_playerwalk).
I don't know whats causing this issue. I tried to resolve it all of last night but did not succeed.
Players movement script
Players shooting script
Codes in "key press" event in player object (these have to do with player states like jumping, crouching, pointing up, standing etc)
Can someone take a look at my code and tell me what I need to fix or add (please give an example because I'm not very proficient at code) to correct the issue?
Any help would be greatly appreciated!
Yesterday, I decided to have player shoot continuously by holding down key press. Now when I'm running and holding down the shoot button, the player shoots continuously, but doesn't move forward. He just remains in the same spot while playing the walking sprite (spr_playerwalk).
I don't know whats causing this issue. I tried to resolve it all of last night but did not succeed.
Players movement script
Code:
if keyboard_check(ord("D")) && !duck_key && place_free(x+4,y) && !keyboard_check(ord("A")) && !keyboard_check(ord("F")){
if (place_free(x,y+1)) {
if (place_free(x+4,y+vspeed)) {
sprite_index = spr_playerwalk;
image_speed = .2;
image_xscale = 1;
x+=2.5;//2.5
}
} else {
sprite_index = spr_playerwalk;
image_speed = .2;
image_xscale = 1;
x+=2.5;//2.5
}
} else if keyboard_check(ord("A")) && !duck_key && place_free(x-4,y) && !keyboard_check(ord("D")) && !keyboard_check(ord("F"))
{
if (place_free(x,y+1)) {
if (place_free(x-4,y+vspeed)) {
sprite_index = spr_playerwalk;
image_speed = .2;
image_xscale = -1;
x-=2.5;//2.5
}
} else {
x-=2.5;//2.5
sprite_index = spr_playerwalk;
image_speed = .2;
image_xscale = -1;
}
}
else {
sprite_index = spr_playerstand;
image_speed = .03 //original .1
}
Code:
if (bullets > 2)
{
if (ducking = true) {
if (image_xscale > 0) {
b=instance_create(x+16,y-1,obj_bullet);
b.direction = 0
b.speed = 9;
b.image_angle = b.direction
}
if (image_xscale < 0) {
b=instance_create(x-16,y-1,obj_bullet);
b.direction = 180
b.speed = 9;
b.image_angle = b.direction
}
}
else if (image_xscale > 0) {
b=instance_create(x+16,y-8,obj_bullet);
b.direction = 0;
b.speed = 9;
b.image_angle = b.direction
b.image_angle = b.direction
} else if (image_xscale < 0){
b=instance_create(x-16,y-8,obj_bullet)
b.direction = 180;
b.speed = 9;
b.image_angle = b.direction
}
}
bullets -= 1;
if (alarm[7] == -1) alarm[7] = 7
Codes in "key press" event in player object (these have to do with player states like jumping, crouching, pointing up, standing etc)
Code:
if (state == 'move' && hspeed > 0 && canshoot = true && health > 0) {
image_speed = .2;
state = 'playershoot' ;
}
else if (!place_meeting(x,y,obj_solid)&& canshoot = true && health > 0) {
image_speed = .2;
state = 'move'
}
else if (state == 'move' && canshoot = true && ducking = true && health > 0) {
image_speed = .2;
sprite_index = spr_playerduckshoot;
state = 'playershoot' ;
}
else if (!place_meeting(x,y,obj_solid) && pointup = true && health > 0) {
image_speed = .2;
sprite_index = spr_playerpointup;
state = 'move'
}
else if (!place_meeting(x,y,obj_solid) && ducking = true && health > 0) {
image_speed = .2;
sprite_index = spr_playerduckshoot;
state = 'move'
}
Can someone take a look at my code and tell me what I need to fix or add (please give an example because I'm not very proficient at code) to correct the issue?
Any help would be greatly appreciated!
Last edited: