FAQ
1
// Pac Man Ghost Movement Code
2
if (place_snapped(64,64)){
3
var changed = false;
4
var randomDir = irandom_range(1,4);
5
6
if (hspeed == 0){
7
if (randomDir == 1){
8
if (!place_meeting(x - ghostSpeed, y, obj_wall)){
9
speed = ghostSpeed
10
direction = 180;
11
changed = true;
12
}
13
} else if (randomDir == 2){
14
if (!place_meeting(x + ghostSpeed, y, obj_wall)){
15
speed = ghostSpeed
16
direction = 0;
17
changed = true;
18
}
19
}
20
}
21
if (vspeed == 0 and changed == false){
22
if (randomDir == 1){
23
if (!place_meeting(x, y - ghostSpeed, obj_wall)){
24
speed = ghostSpeed
25
direction = 90;
26
}
27
} else if (randomDir == 2){
28
if (!place_meeting(x, y + ghostSpeed, obj_wall)){
29
speed = ghostSpeed
30
direction = 270;
31
}
32
}
33
}
34
}
Copied!
Space Invader Style Enemy Movement
Object Following a Mouse
Changing Background Colors in Code.
Export as PDF
Copy link