FAQ

// Pac Man Ghost Movement Code
if (place_snapped(64,64)){
	var changed = false;
	var randomDir = irandom_range(1,4);
	
	if (hspeed == 0){
		if (randomDir == 1){
			if (!place_meeting(x - ghostSpeed, y, obj_wall)){
				speed = ghostSpeed
				direction = 180;
				changed = true;
			}
		} else if (randomDir == 2){
			if (!place_meeting(x + ghostSpeed, y, obj_wall)){
				speed = ghostSpeed
				direction = 0;
				changed = true;
			}
		}
	}
	if (vspeed == 0 and changed == false){
		if (randomDir == 1){
			if (!place_meeting(x, y - ghostSpeed, obj_wall)){
				speed = ghostSpeed
				direction = 90; 
			}
		} else if (randomDir == 2){
			if (!place_meeting(x, y + ghostSpeed, obj_wall)){
				speed = ghostSpeed
				direction = 270;
			}
		}
	}
}

Last updated