1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

help making more than one enemy

Discussion in 'Programming' started by 1213brett, Feb 15, 2020.

  1. 1213brett

    1213brett Member

    Joined:
    May 30, 2018
    Posts:
    27
    Hi I have more than one enemy called goblin and its almost like they take turns moving and attacking I don't know how to make them attack and move at once.

    in create event of other object
    globalvar grid;
    grid = mp_grid_create(0, 0, room_width div 16, room_height div 16, 16, 16);
    mp_grid_add_instances(grid, wall, true);





    in goblin create event

    global.goblinpath = path_add();
    WalkUp=true
    Attack=false


    in goblin step event

    depth=-y
    if( abs(angle_difference(-90, direction)) > 90){
    WalkUp = true
    }else{
    WalkUp = false
    }
    if( abs(angle_difference(180, direction)) < 90){
    FaceLeft = true
    }else{
    FaceLeft = false
    }
    if x<= player.x+3 and x>= player.x-3 and y<=player.y+3 and y>= player.y-3 Attack = true else Attack = false

    if mp_grid_path(grid,global.goblinpath, x, y, player.x, player.y, 0)
    {
    path_start(global.goblinpath, 1, 0, 0);
    }


    in goblin draw event

    if Attack = false && WalkUp = false && FaceLeft=false draw_sprite_ext(sprite8,-1,x,y,1,1,0,c_white,1)
    if Attack = false && WalkUp = true && FaceLeft=false draw_sprite_ext(sprite81,-1,x,y,1,1,0,c_white,1)
    if Attack = false && WalkUp = false && FaceLeft=true draw_sprite_ext(sprite8,-1,x,y,-1,1,0,c_white,1)
    if Attack = false && WalkUp = true && FaceLeft=true draw_sprite_ext(sprite81,-1,x,y,-1,1,0,c_white,1)

    if WalkUp = false && FaceLeft=false && Attack = true draw_sprite_ext(sprite82,-1,x,y,1,1,0,c_white,1)
    if WalkUp = true && FaceLeft=false && Attack = true draw_sprite_ext(sprite821,-1,x,y,1,1,0,c_white,1)
    if WalkUp = false && FaceLeft=true && Attack = true draw_sprite_ext(sprite82,-1,x,y,-1,1,0,c_white,1)
    if WalkUp = true && FaceLeft=true && Attack = true draw_sprite_ext(sprite821,-1,x,y,-1,1,0,c_white,1)
     
  2. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    142
    Don't make goblinpath global, they currently share the same path because of this.
     
    devKathy likes this.
  3. 1213brett

    1213brett Member

    Joined:
    May 30, 2018
    Posts:
    27
    thank you
     
    devKathy likes this.
  4. Alaska Minds

    Alaska Minds Member

    Joined:
    Feb 11, 2020
    Posts:
    12
    Last edited: Feb 15, 2020

Share This Page