Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MOVED += movementspeed;
- while (MOVED > 0) {
- if (distance_to_object(obj_player) < 144) {
- if DIRGOING == -1 {
- DIRGOING = scr_partdir(point_direction(x, y, obj_player.x, obj_player.y), 4);
- }
- else {
- if DIRGOING == -1 {
- DIRGOING = scr_partdir(random(360), 4);
- }
- }
- }
- var _temp;
- _temp = min(CLOSE, MOVED);
- MOVED -= _temp;
- moveX = lengthdir_x(_temp, DIRGOING);
- moveY = lengthdir_y(_temp, DIRGOING)
- if (!collision_point(x + moveX + (sign(moveX) * 16), y, par_collideterrain, false, true)) then x += moveX;
- else DIRGOING += choose(90, -90);
- if (!collision_point(x, y + moveY + (sign(moveY) * 16), par_collideterrain, false, true)) then y += moveY;
- else DIRGOING += choose(90, -90);
- CLOSE -= _temp;
- if CLOSE == 0 {
- CLOSE = gridsize;
- DIRGOING = -1;
- }
- }
- switch (DIRGOING) {
- case 270:
- {
- sprite_index = spriteD;
- break;
- }
- case 0:
- {
- sprite_index = spriteR;
- break;
- }
- case 90:
- {
- sprite_index = spriteU;
- break;
- }
- case 180:
- {
- sprite_index = spriteL;
- break;
- }
- }
- if false //If the mob is not moving it stops the animation.
- {
- image_speed = 0;
- image_index = 0;
- }
- else {
- image_speed = 0.2;
- }
Add Comment
Please, Sign In to add comment