Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Collide





The collide module header is lapin/collide.h
typedef enum e_bunny_collision_type
{
     BCT_DOT,
     BCT_CIRCLE,
     BCT_LINE,
     BCT_TRIANGLE,
     BCT_RECTANGLE,
     BCT_QUAD,
     BCT_EQUATION,
     LAST_COLLISION_TYPE

} t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌t‌y‌p‌e;

Description

     This enumeration is used by t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n to dynamicaly type itself into one of its attribute.

Symbols



INDEX


Description

     This union contains every kind of collidable shape and an enumeration field to allow runtime type identification.

To configure this union, you must set to the type attribute a value from t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌t‌y‌p‌e, accordingly to the collision shape you want to set. If you need to use the t‌_‌b‌u‌n‌n‌y‌_‌d‌o‌t‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n attribute, for example, you will have to set type to BCT_DOT.

Attributes




INDEX


Description

     This structure represents a dot in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a circle in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a line in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a triangle in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a rectangle in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a quad in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union.

Attributes




INDEX


Description

     This structure represents a equation in a 2D space. This structure is part of the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n union, but may be used separately as the equation collide function returns more than a collide/not collide information.

The equation computed for this collision is second degree function:
     a * x * x + b * x + c

Attributes

  • t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌t‌y‌p‌e type:
         The type identification enumerated field. It must be set to BCT_EQUATION if you use this structure.
  • t‌_‌b‌u‌n‌n‌y‌_‌a‌c‌c‌u‌r‌a‌t‌e‌_‌p‌o‌s‌i‌t‌i‌o‌n coord[2]:
         Coordinates of the rectangle in which the equation will be taken in consideration.
  • t‌_‌b‌u‌n‌n‌y‌_‌a‌c‌c‌u‌r‌a‌t‌e‌_‌p‌o‌s‌i‌t‌i‌o‌n amplitude:
         The mathematical amplitude of the square. You may wish to have a direct correspondance between coord[1], which contains the size in pixels and amplitude which contains a size on an arbitrary scale. To do so, simply set the same values in coord[1] and in amplitude.
  • double $a:
         The parameter a in the second degree equation.
  • double $b:
         The parameter b in the second degree equation.
  • double $c:
         The parameter c in the second degree equation.
  • bool origin_at_center:
         If this field is true, the origina will be placed at the center of the equation square. If false, it will depend of flipx and flipy attributes, but if they are both false, the origin will be on the top left corner.
  • bool flipx:
         If this field is false, the X axis goes from left to right.
    If it is true, from right to left. It will move the origin from the left side to the right side of the equation square if origin_at_center is false.
  • bool flipy:
         If this field is false, the Y axis goes from top to bottom.
    If it is true, from bottom to top. It will move the origin from the the top side to the bottom side of the equation square if origin_at_center is false.



INDEX


Description

     Test if the two shapes collide and return true or false accordingly.

For dot-equation collision, you should prefer use b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌e‌q‌u‌a‌t‌i‌o‌n‌_‌d‌o‌t which return not only a bool but the position and the angle of collision.

Parameters


Return value

A true if shapes collide, else false.




INDEX


Description

     Draw the sent collision shape on the target buffer. Use color to draw.

b‌u‌n‌n‌y‌_‌d‌r‌a‌w‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌s‌h‌a‌p‌e will use b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌p‌i‌x‌e‌l, b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌l‌i‌n‌e and b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌c‌i‌r‌c‌l‌e so it will not work on t‌_‌b‌u‌n‌n‌y‌_‌p‌i‌x‌e‌l‌a‌r‌r‌a‌y unless you previously set the function pointer and code yourself those functions.

Also, because there is a lot of writes, this function may be slow if called for a lot of complex shapes.

Parameters




INDEX


Description

     This structure is returned by b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌s‌i‌o‌n‌_‌e‌q‌u‌a‌t‌i‌o‌n‌_‌d‌o‌t to indicate where the collision occured and what is the inclination level on this point.

Attributes




INDEX


Description

     Test the collision between an equation square and a dot shape. Returns the complete collision information.


Return value

A Return a t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e‌_‌p‌o‌i‌n‌t which contains the point at the surface of the equation where the collision happened and which is the inclination level of the equation at this point.




INDEX


Description

     Test the collision a circle at position circle_coord of radius radius with dot.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision of the circle a of radius a_radius with the circle b of radius b_radius.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX


Description

     Test the collision between the two shapes.

Parameters


Return value

true or false depending if there is a collision or not.


Additional informations

This function is part of the first version of the collide module and can be quite handy for simple program, but for more complex ones, consider using the b‌u‌n‌n‌y‌_‌c‌o‌l‌l‌i‌d‌e system.



INDEX