62 lines
2.7 KiB
HTML
62 lines
2.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Collision checking</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Collision checking</h3>
|
|
|
|
When planning motions or deciding on certain actions, it is often important
|
|
to see whether there are collisions with other objects at certain places. The
|
|
following routines can be used for this. All these have three arguments in
|
|
common: The argument <TT>obj</TT> can be an object, the keyword <TT><B>all</b></tt>,
|
|
or the id of an instance. The argument <TT>prec</TT> indicates whether
|
|
the check should be precise or only based on the bounding box of the instance.
|
|
Precise checking is only done when the sprite for the instance has the
|
|
precise collision checking set. The argument <TT>notme</TT> can be set
|
|
to true to indicate that the calling instance should not be checked.
|
|
All these functions return either the id of one of the instances that
|
|
collide, or they return a negative value when there is no collision.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>collision_point(x,y,obj,prec,notme)</b></tt>
|
|
This function tests whether at point (x,y) there is a collision
|
|
with entities of object obj. <br>
|
|
<tt><b>collision_rectangle(x1,y1,x2,y2,obj,prec,notme)</b></tt>
|
|
This function tests whether there is a collision between the (filled)
|
|
rectangle with the indicated opposite corners and entities of object obj.
|
|
For example, you can use this to test whether an area is free of obstacles.<br>
|
|
<tt><b>collision_circle(xc,yc,radius,obj,prec,notme)</b></tt>
|
|
This function tests whether there is a collision between the (filled)
|
|
circle centered at position (xc,yc) with the given radius and entities
|
|
of object obj. For example, you can use this to test whether there is
|
|
an object close to a particular location.<br>
|
|
<tt><b>collision_ellipse(x1,y1,x2,y2,obj,prec,notme)</b></tt>
|
|
This function tests whether there is a collision between the (filled)
|
|
ellipse with the indicated opposite corners and entities of object obj. <br>
|
|
<tt><b>collision_line(x1,y1,x2,y2,obj,prec,notme)</b></tt>
|
|
This function tests whether there is a collision between the line segment
|
|
from (x1,y1) to (x2,y2) and entities of object obj. This is a powerful
|
|
function. You can e.g. use it to test whether an instance can see another
|
|
instance by checking whether the line segment between them intersects a wall.<br>
|
|
</blockquote>
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
collision checking
|
|
|
|
collision_point()
|
|
collision_rectangle()
|
|
collision_circle()
|
|
collision_ellipse()
|
|
collision_line()
|
|
|
|
--> |