D
dragon_slayer25
Guest
I have spent the last week staring at my code for my enemy. all i want the enemy to do is move to the side when it collides with the wall it goes backwards. i have tried to look it up but to no luck. someone please help me i am only a beginner at coding.
here is my code for my enemy
//step event
if (place_meeting (x+(1), y, obj_wall))
{
phy_position_x -= (xspeed);
}
else if (place_meeting (x-(1), y, obj_wall))
{
phy_position_x += (xspeed);
}
if (position_empty (x+(1) , y) && start1 == false)
{
phy_position_x +=(xspeed);
start1 = true;
}
else if (position_empty (x-(1) , y) && start1 == true)
{
phy_position_x -= (xspeed);
start1 = false;
}
and here is my code in the create event
xspeed = (3);
start1 = false;
someone please help me with this so I can learn from this
here is my code for my enemy
//step event
if (place_meeting (x+(1), y, obj_wall))
{
phy_position_x -= (xspeed);
}
else if (place_meeting (x-(1), y, obj_wall))
{
phy_position_x += (xspeed);
}
if (position_empty (x+(1) , y) && start1 == false)
{
phy_position_x +=(xspeed);
start1 = true;
}
else if (position_empty (x-(1) , y) && start1 == true)
{
phy_position_x -= (xspeed);
start1 = false;
}
and here is my code in the create event
xspeed = (3);
start1 = false;
someone please help me with this so I can learn from this