Designing Games with Game Maker - YoYo Games
Designing Games with Game Maker - YoYo Games
Designing Games with Game Maker - YoYo Games
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
mp_grid_add_instances(id,obj,prec) Marks all cells that intersect an<br />
instance of the indicated object as being forbidden. You can also use an<br />
individual instance by making obj the id of the instance. Also you can use the<br />
keyword all to indicate all instances of all objects. prec indicates whether<br />
precise collision checking must be used (will only work if precise checking is<br />
enabled for the sprite used by the instance).<br />
mp_grid_path(id,path,xstart,ystart,xgoal,ygoal,allowdiag)<br />
Computes a path through the grid. path must indicate an existing path that<br />
will be replaced by the computer path. xstart and ystart indicate the start of<br />
the path and xgoal and ygoal the goal. allowdiag indicates whether diagonal<br />
moves are allowed instead of just horizontal or vertical. The function returns<br />
whether it succeeded in finding a path. (Note that the path is independent of<br />
the current instance; It is a path through the g rid, not a path for a specific<br />
instance.)<br />
mp_grid_draw(id) This function draws the grid <strong>with</strong> green cells being free<br />
and red cells being forbidden. This function is slow and only provided as a<br />
debug tool.<br />
Collision checking<br />
When planning motions or deciding on certain actions, it is often important to see whether<br />
there are collisions <strong>with</strong> other objects at certain places. The following routines can be used for<br />
this. All these have three arguments in common: The argument obj can be an object, the<br />
keyword all, or the id of an instance. The argument prec indicates whether the check should<br />
be precise or only based on the bounding box of the instance. Precise checking is only done<br />
when the sprite for the instance has the precise collision checking set. The argument notme<br />
can be set to true to indicate that the calling instance should not be checked. All these<br />
functions return either the id of one of the instances that collide, or they return a negative<br />
value when there is no collision.<br />
collision_point(x,y,obj,prec,notme) This function tests whether at<br />
point (x,y) there is a collision <strong>with</strong> entities of object obj.<br />
collision_rectangle(x1,y1,x2,y2,obj,prec,notme) This function<br />
tests whether there is a collision between the (filled) rectangle <strong>with</strong> the<br />
indicated opposite corners and entities of object obj. For example, you can use<br />
this to test whether an area is free of obstacles.