Designing Games with Game Maker - YoYo Games
Designing Games with Game Maker - YoYo Games
Designing Games with Game Maker - YoYo Games
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
e careful how and when you apply it. Please keep these remarks in mind when you use any<br />
of the following functions.<br />
Different forms of motion planning are provided by <strong>Game</strong> <strong>Maker</strong>. The simplest form lets an<br />
instance take a step towards a particular goal position, trying to go straight if possible but<br />
taking a different direction if required. These functions should be used in the step event of an<br />
instance. They correspond to the motion planning actions that are also available:<br />
mp_linear_step(x,y,stepsize,checkall) This function lets the<br />
instance take a step straight towards the indicated position (x,y). The size of<br />
the step is indicated by the stepsize. If the instance is already at the<br />
position it will not move any further. If checkall is true the instance will stop<br />
when it hits an instance of any object. If it is false it only stops when hitting a<br />
solid instance. Note that this function does not try to make detours if it meets<br />
an obstacle. It simply fails in that case. The function returns whether or not<br />
the goal position was reached.<br />
mp_linear_step_object(x,y,stepsize,obj) Same as the function<br />
above but this time only instances of obj are considered as obstacles. obj can<br />
be an object or an instance id.<br />
mp_potential_step(x,y,stepsize,checkall) Like the previous<br />
function, this function lets the instance take a step towards a particular<br />
position. But in this case it tries to avoid obstacles. When the instance would<br />
run into a solid instance (or any instance when checkall is true) it will change<br />
the direction of motion to try to avoid the instance and move around it. The<br />
approach is not guaranteed to work but in most easy cases it will effectively<br />
move the instance towards the goal. The function returns whether or not the<br />
goal was reached.<br />
mp_potential_step_object(x,y,stepsize,obj) Same as the function<br />
above but this time only instances of obj are considered as obstacles. obj can<br />
be an object or an instance id.<br />
mp_potential_settings(maxrot,rotstep,ahead,onspot) The<br />
previous function does its work using a number of parameters that can be<br />
changed using this function. Globally the method works as follows. It first tries<br />
to move straight towards the goal. It looks a number of steps ahead which can<br />
be set <strong>with</strong> the parameter ahead (default 3). Reducing this value means that<br />
the instance will start changing direction later. Increasing it means it will start