giraffeman210
Member
I am trying to make random enemy movement work for my maze game but can't find any tutorials on how to do it. I am trying to make it work so the enemies move in random directions but can not choose backwards or where there is a wall. Below is a response I had gotten but I don't know how to add the actual movement into this. I know its checking a bunch of stuff but how do I add movement to it? I am using DnD and GMS2. Thank you!
"because there is not a do until loop in drag in drop your best bet is each time you wish to move to do the following
set a variable called dchoosen to false
repeat 20 times
start block
test variable dchoosen false
check collision 64 0 wall relative not
test chance 4
start block
set variable x 64 relative
set variable dchosen true
end block
test variable dchoosen false
check collision -64 0 wall relative not
test chance 4
start block
set variable x -64 relative
set variable dchosen true
end block
test variable dchoosen=false
check collision 0 64 wall relative not
test chance 4
start block
set variable y 64 relative
set variable dchosen=true
end block
test variable dchoosen=false
check collision 0 -64 wall relative not
test chance 4
start block
set variable y -64 relative
set variable dchosen=true
end block
endblock
this is actually much easer and fasteer to do in code than block but that should work"
"because there is not a do until loop in drag in drop your best bet is each time you wish to move to do the following
set a variable called dchoosen to false
repeat 20 times
start block
test variable dchoosen false
check collision 64 0 wall relative not
test chance 4
start block
set variable x 64 relative
set variable dchosen true
end block
test variable dchoosen false
check collision -64 0 wall relative not
test chance 4
start block
set variable x -64 relative
set variable dchosen true
end block
test variable dchoosen=false
check collision 0 64 wall relative not
test chance 4
start block
set variable y 64 relative
set variable dchosen=true
end block
test variable dchoosen=false
check collision 0 -64 wall relative not
test chance 4
start block
set variable y -64 relative
set variable dchosen=true
end block
endblock
this is actually much easer and fasteer to do in code than block but that should work"