• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Enemy obsession with the rigth wall

L

Lerchprinz

Guest
Ahoi my friends.
i build this enemy that is patrolling on the x and y axis and dashing towards the player when the x or y position are the same. for some reason the enemy keeps driving to right walls after a dash. it is not all the time, but it happens frequently. The other walls are fine. it is just the right one... heres the code:

create:

alarm[0] = 10;
is_dashing = false;
is_opening = false;
is_closing = false;


step:

if(!is_opening && !is_dashing && !is_closing){
if(vspeed < 0){
sprite_index = spr_Drill_drive_back;
}else if(vspeed > 0){
sprite_index = spr_Drill_drive_front;
}else if(hspeed < 0){
sprite_index = spr_Drill_drive_left;
}else if(hspeed > 0){
sprite_index = spr_Drill_drive_right;
}


speed = 1.5;
}
//X and Y Axis Scanner
if(!is_dashing && !is_closing && !is_opening){
if((obj_Player.x <= x+5 && obj_Player.x >= x-5) && obj_Player.y < y){
is_opening = true;
sprite_index = spr_Drill_open_back;
}else if((obj_Player.x <= x+5 && obj_Player.x >= x-5) && obj_Player.y > y){
is_opening = true;
sprite_index = spr_Drill_open_front;
}else if((obj_Player.y <= y+5 && obj_Player.y >= y-5) && obj_Player.x > x){
is_opening = true;
sprite_index = spr_Drill_open_right;
}else if((obj_Player.y <= y+5 && obj_Player.y >= y-5) && obj_Player.x < x){
is_opening = true;
sprite_index = spr_Drill_open_left;
}
}
if(is_dashing){
if(sprite_index = spr_Drill_dash_right){
direction = 0;
}else if(sprite_index = spr_Drill_dash_left){
direction = 180;
}else if(sprite_index = spr_Drill_dash_back){
direction = 90;
}else if(sprite_index = spr_Drill_dash_front){
direction = 270;
}
speed = 10;
}
if(is_closing){
if(sprite_index = spr_Drill_dash_right){
sprite_index = spr_Drill_close_right;
}else if(sprite_index = spr_Drill_dash_left){
sprite_index = spr_Drill_close_left;
}else if(sprite_index = spr_Drill_dash_back){
sprite_index = spr_Drill_close_back;
}else if(sprite_index = spr_Drill_dash_front){
sprite_index = spr_Drill_close_front;
}
}
colhor =collide_horizontally(obj_solid) ;
colver = collide_vertically(obj_solid)


alarm:

randomize();
direction = choose(0,90,180,270);
if(colhor){
direction= -direction;
}else if(colver){
direction= -direction;
}
speed = 1.5
alarm[0] = irandom_range(60,90);


animation end:

if(sprite_index == spr_Drill_open_back){
is_opening = false;
is_dashing = true;
sprite_index = spr_Drill_dash_back;
}else if(sprite_index == spr_Drill_open_front){
is_opening = false;
is_dashing = true;
sprite_index = spr_Drill_dash_front;
}else if(sprite_index == spr_Drill_open_left){
is_opening = false;
is_dashing = true;
sprite_index = spr_Drill_dash_left;
}else if(sprite_index == spr_Drill_open_right){
is_opening = false;
is_dashing = true;
sprite_index = spr_Drill_dash_right;
}
if(sprite_index == spr_Drill_close_back){
is_opening = false;
is_dashing = false;
is_closing = false;

}else if(sprite_index == spr_Drill_close_front){
is_opening = false;
is_dashing = false;
is_closing = false;

}else if(sprite_index == spr_Drill_close_left){
is_opening = false;
is_dashing = false;
is_closing = false;

}else if(sprite_index == spr_Drill_close_right){
is_opening = false;
is_dashing = false;
is_closing = false;
}


colliosion with obj Solid:

is_dashing = false;
is_closing = true;
alarm[0] = 10;
 
Top