B
betitoas1
Guest
Well, i am making a boss, and it moves by itself(randomly directions,0,90,180,270) all works perfectly except this, i have created a room for the boss and he goes outside of the room while he's walking, how can i make that the boss stays in the room bounds?
This is the code i'm using for the movement of the boss(He only chooses a random direction and he moves it's very simple)
This is the room:
The boss is the red square, it's for a test xD
And this is the in-game room, if you see the boss is outside the map.
This is the code i'm using for the movement of the boss(He only chooses a random direction and he moves it's very simple)
Code:
///Create Event
hpdremboss = 100;
dir = 1;
canmove = true;
sp = 1.5;
///Step Event
//Moves randomly
dir = choose(1,2,3,4,dir,dir,dir,dir);
//Cases
if canmove = true {
switch(dir)
{
case 1:
motion_set(0,sp);
canmove = false;
alarm[0] = 60;
break;
case 2:
motion_set(90,sp);
canmove = false;
alarm[0] = 60
break;
case 3:
motion_set(180,sp);
canmove = false;
alarm[0] = 60
break;
case 4:
motion_set(270,sp);
canmove = false;
alarm[0] = 60
break;
}
}
The boss is the red square, it's for a test xD
And this is the in-game room, if you see the boss is outside the map.