diff --git a/reference.html b/reference.html index c5cebbd..b4b6118 100644 --- a/reference.html +++ b/reference.html @@ -59,6 +59,8 @@

Module overview

+
HardonCollider
+
The collider class.
new()
Create a new collider instance.
HC:clear()
@@ -475,12 +477,20 @@ Timer.add(5, function() HC:setSolid(player) end)

Module overview

-
shapes.PolygonShape
-
A polygon shape.
-
shapes.CircleShape
-
A circle shape.
-
shapes.PointShape
-
A point shape.
+
shapes.ConvexPolygonShape
+
Convex polygon shape class.
+
shapes.ConcavePolygonShape
+
Concave polygon shape class.
+
shapes.CircleShape
+
Circle shape class.
+
shapes.PointShape
+
Point shape class.
+
shapes.newPolygonShape()
+
Creates a polygon shape.
+
shapes.newCircleShape()
+
Creates a circle shape.
+
shapes.newPointShape()
+
Creates a point shape.
shape:contains()
Test if shape contains a point.
shape:intersectsRay()
@@ -506,10 +516,10 @@ Timer.add(5, function() HC:setSolid(player) end)
- -
-

class PolygonShape(x1,y1, ..., xn,yn)^ top

-

class PolygonShape(polygon)

+ +
+

function newPolygonShape(x1,y1, ..., xn,yn)^ top

+

function newPolygonShape(polygon)

Construct a shape using a non-intersecting ploygon.

You can either specify the coordinates as with hardoncollider.addPolygon() or use an instance of the Polygon class.

Parameters: @@ -527,13 +537,13 @@ Timer.add(5, function() HC:setSolid(player) end)
Example: -
shape = shapes.PolygonShape(100,100, 200,200, 300,100)
+
shape = shapes.newPolygonShape(100,100, 200,200, 300,100)
- -
-

class CircleShape(cx,cy, radius)^ top

+ +
+

function newCircleShape(cx,cy, radius)^ top

Construct a circular shape.

Parameters:
@@ -550,13 +560,13 @@ Timer.add(5, function() HC:setSolid(player) end)
Example: -
shape = shapes.CircleShape(400,300, 100)
+
shape = shapes.newCircleShape(400,300, 100)
- -
-

class PointShape(x,y)^ top

+ +
+

function newPointShape(x,y)^ top

Construct a point shape.

Parameters:
@@ -571,7 +581,7 @@ Timer.add(5, function() HC:setSolid(player) end)
Example: -
shape = shapes.PointShape(400,300)
+
shape = shapes.newPointShape(400,300)
@@ -874,6 +884,7 @@ end

class Polygon(x1,y1, ..., xn,yn)^ top

+

Syntax depends on used class system. Shown syntax works for bundled hump.class and slither.

Construct a polygon.

At least three points that are not collinear (being on a straight line) are needed to construct the polygon. If there are collinear points, these points will be removed so that the overall shape of the polygon is not changed.

@@ -890,10 +901,8 @@ end
Example: -
poly = polygon.Polygon(10,10, 40,50, 70,10, 40,30)
-

polygon.Polygon looks rather verbose - that is why you can actually - call the module like a function to create an instance of the Polygon class:

-
poly = polygon(10,10, 40,50, 70,10, 40,30)
+
Polygon = require 'hardoncollider.polygon'
+poly = Polygon(10,10, 40,50, 70,10, 40,30)
@@ -1096,7 +1105,7 @@ end

function polygon:mergedWith(other)^ top

-

Create a merged polygon of two polygons if, and only if the two polygons share one edge. If the polygons share more than one edge, the result may be erroneous.

+

Create a merged polygon of two polygons if, and only if the two polygons share one complete edge. If the polygons share more than one edge, the result may be erroneous.

This function does not change either polygon, but rather create a new one.

Parameters:
@@ -1203,6 +1212,7 @@ end

Spatialhash(cell_size)^ top

+

Syntax depends on used class system. Shown syntax works for bundled hump.class and slither.

Create a new spatial hash given a cell size.

Choosing a good cell size depends on your application. To get a decent speedup, the average cell should not contain too many objects, nor should a single object @@ -1221,10 +1231,8 @@ end

Example: -
hash = spatialhash.Spatialhash(150)
-

As with Polygon(), you can call the module as - a shortcut to the above:

-
hash = spatialhash(150)
+
Spatialhash = require 'hardoncollider.spatialhash'
+hash = Spatialhash(150)
@@ -1389,6 +1397,32 @@ end
+ +
+

function hash:draw(draw_mode, show_empty, print_key)^ top

+

Draw hash cells on the screen, mostly for debug purposes

+
Parameters: +
+
string draw_mode
+
Either 'fill' or 'line'. See the LÖVE wiki.
+
boolean show_empty (true)
+
Wether to draw empty cells.
+
boolean print_key (false)
+
Wether to print cell coordinates.
+
+
+
Returns: +
+
Nothing
+
+
+
Example: +
love.graphics.setColor(160,140,100,100)
+hash:draw('line', true, true)
+hash:draw('fill', false)
+
+
+