Box2D extension and library

A Box2D extension.

File:
box2d.lib, box2d_next.dll
Version:
1.0
Author:
Marcus Johansson

Contents

Details
Constants
Sub routines


Details

(From the naalaadeveloper.com forum:)

It's a little hard to explain the setup of this extension. The box2d.lib consists of two "parts".

The first part is just a port of what the C++ version of Box2D is like. This is pretty hard to use for a new beginner BASIC programmer. For example, Box2D doesn't care about drawing the world that it simulates. That's up to the user. And setting up bodies and stuff is far from one-line things. Anyhow, all these standard Box2D functions begin with B2_.

So, with the above in mind, the second part of the library is all helper stuff that I strongly suggest that you use. You can and should, of course, use the non-helper part too when you feel ready for it :) I mean, that's when the cool things really start. The helper functions start with B2H_.

There are helper functions for creating "objects" (bodies with fixtures, images and so forth). But most of the helper functions are related to drawing. OpenGL is used, which means you can't use any of the normal NaaLaa commands for writing text or drawing images and other primitives. The first example shows you the new drawing functions that aren't really related to Box2D.

This document should absolutely not be seen as a Box2D manual. Because that would certainly be one crappy manual. For more information about Box2D, you should visit the Box2D website. The examples provided with this NaaLaa extension try to cover as much as possible.


Constants

Body types

Name
Description
B2_STATIC_BODY
B2_KINEMATIC_BODY
B2_DYNAMIC_BODY


Subroutines

World

Name
Parameters
Brief description
function
B2_Init
x#, y#
Initialize and create world.
procedure
B2_SetVelocityIterations
velocityIterations
Set number of velocity iterations per update.
procedure
B2_SetPositionIterations
positionIterations
Set number of position iterations per update.
procedure
B2_Step
timeStep#
Update Box2D with time step.

Bodies

Name
Parameters
Brief description
function
B2_CreateBody
type, x#, y#
Create body.
procedure
B2_DestroyBody
body
Destroy body.
function
B2_CreateBodyWithDefinition
&def?
Create body from definition.
function
B2_BodyPosition#[]
body
Get body's position.
function
B2_BodyAngle#
body
Get body's angle.
procedure
B2_BodySetTransform
body, x#, y#, a#
Set body's position and angle.
function
B2_BodyActive
body
Return true if body is active.
procedure
B2_BodySetActive
body, value
Set body active flag.
function
B2_BodyAwake
body
Return true if body is awake.
procedure
B2_BodySetAwake
body, value
Set body awake flag.
function
B2_BodyBullet
body
Return true if body is bullet.
procedure
B2_BodySetBullet
body, value
Set body bullet flag.
function
B2_BodyFixedRotation
body
Return true if body has fixed rotation.
procedure
B2_BodySetFixedRotation
body, value
Set body fixed rotation flag.
function
B2_BodySleepingAllowed
body
Return true if sleeping is allowed for body .
procedure
B2_BodySetSleepingAllowed
body, value
Set body sleeping allowed flag.
function
B2_BodyLinearVelocity#[]
body
Get body's linear velocity.
procedure
B2_BodySetLinearVelocity
body, x#, y#
Set body's linear velocity.
function
B2_BodyAngularVelocity#
body
Get body's angular velocity.
procedure
B2_BodySetAngularVelocity
body, v#
Set body's angular velocity.
function
B2_BodyLinearDamping#
body
Get body's linear damping.
procedure
B2_BodySetLinearDamping
body, d#
Set body's linear damping.
function
B2_BodyAngularDamping#
body
Get body's angular damping.
procedure
B2_BodySetAngularDamping
body, d#
Set body's angular damping.
procedure
B2_BodyApplyForce
body, forceX#, forceY#, pointX#, pointY#
Apply force to body.
procedure
B2_BodyApplyForce_v
body, force#[], point#[]
Apply force to body.
procedure
B2_BodyApplyTorque
body, torque#
Apply toque to body.
procedure
B2_BodyApplyLinearImpulse
body, impulseX#, impulseY#, pointX#, pointY#
Apply linear impulse to body.
procedure
B2_BodyApplyLinearImpulse_v
body, impulse#[], point#[]
Apply linear impulse to body.
procedure
B2_BodyApplyAngularImpulse
body, impulse#
Apply angular impulse to body.
procedure
B2_BodyDestroyFixture
body, fixture
Destroy fixture.
function
B2_BodyWorldCenter#[]
body
Get world center point.
function
B2_BodyLocalCenter#[]
body
Get local center point.
function
B2_BodyWorldPoint#[]
body, x#, y#
Get world point from local.
function
B2_BodyLocalPoint#[]
body, x#, y#
Get local point from world.
function
B2_BodyWorldVector#[]
body, x#, y#
Get world vector from local.
function
B2_BodyLocalVector#[]
body, x#, y#
Get local vector from world.
function
B2_BodyMass#
body
Get body mass.

Shapes

Name
Parameters
Brief description
function
B2_CreateCircleShape
x#, y#, r#
Create circle shape.
function
B2_CreateBoxShape
hx#, hy#
Create box shape.
function
B2_CreateBoxShape2
hx#, hy#, cx#, cy#, a#
Create box shape.
function
B2_CreatePolygonShape
vertices#[][]
Create polygon shape.
function
B2_CreateChainShape
vertices#[][]
Create chain shape.
function
B2_ShapeVertex#[]
shape, index
Get vertex of shape.
procedure
B2_DestroyShape
shape
Destroy shape.

Fixtures

Name
Parameters
Brief description
function
B2_CreateFixture
body, shape, density#, releaseShape
Create fixture with default fixture material.
function
B2_CreateFixtureWithDefinition
body, shape, &def?, releaseShape
Create fixture from definition.

Joints

Name
Parameters
Brief description
function
B2_CreateDistanceJoint
bodyA, bodyB, anchorAX#, anchorAY#, anchorBX#, anchorBY#, collideConnected, frequencyHz#, dampingRatio#
Create distance joint.
function
B2_CreateDistanceJoint_v
bodyA, bodyB, anchorA#[], anchorB#[], collideConnected, frequencyHz#, dampingRatio#
Create distance joint.
function
B2_CreateDistanceJointWC
bodyA, bodyB, collideConnected, frequencyHz#, dampingRatio#
Create distance joint using world centers of the two bodies as anchors.
function
B2_CreateRevoluteJoint
bodyA, bodyB, anchorX#, anchorY#, collideConnected
Create revolute joint.
function
B2_CreateRevoluteJoint_v
bodyA, bodyB, anchor#[], collideConnected
Create revolute joint.
function
B2_RevoluteJointJointAngle#
joint
Get joint angle for revolute joint.
function
B2_RevoluteJointJointSpeed#
joint
Get joint speed for revolute joint.
function
B2_RevoluteJointMotorTorque#
joint, inv_dt#
Get motor torque for revolute joint given the inverse time step.
procedure
B2_RevoluteJointSetMotorSpeed
joint, speed#
Set motor speed for revolute joint.
procedure
B2_RevoluteJointSetMaxMotorTorque
joint, torque#
Set max motor torque for revolute joint.
function
B2_CreatePrismaticJoint
bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, collideConnected
Create prismatic joint.
function
B2_CreatePrismaticJoint_v
bodyA, bodyB, anchor#[], axis#[], collideConnected
Create prismatic joint.
function
B2_CreatePrismaticJointWithDefinition
bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, &def?
Create prismatic joint.
function
B2_CreatePrismaticJointWithDefinition_v
bodyA, bodyB, anchor#[], axis#[], &def?
Create prismatic joint.
function
B2_PrismaticJointJointTranslation#
joint
Get joint translation of prismatic joint.
function
B2_PrismaticJointJointSpeed#
joint
Get joint translation speed of prismatic joint.
function
B2_PrismaticJointMotorForce#
joint, inv_dt#
Get current motor force for prismatic joint given the inverse time step.
procedure
B2_PrismaticJointSetMotorSpeed
joint, speed#
Set motor speed for prismatic joint.
procedure
B2_PrismaticJointSetMaxMotorForce
joint, force#
Set the maximum motor force for prismatic joint.
function
B2_CreatePulleyJoint_v
bodyA, bodyB, groundAnchorA#[], groundAnchorB#[], anchorA#[], anchorB#[], ratio#, collideConnected
Create pulley joint.
function
B2_PulleyJointGroundAnchorA#[]
joint
Get first ground anchor's woorld position of pulley joint.
function
B2_PulleyJointGroundAnchorB#[]
joint
Get second ground anchor's woorld position of pulley joint.
function
B2_PulleyJointLengthA#
joint
Get length between first anchor and ground anchor of pulley joint.
function
B2_PulleyJointLengthB#
joint
Get length between second anchor and ground anchor of pulley joint.
function
B2_PulleyJointRatio#
joint
Get joint pulley ratio.
function
B2_CreateWheelJoint
bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#
Create wheel joint.
function
B2_CreateWheelJoint_v
bodyA, bodyB, anchor#[], axis#[]
Create wheel joint.
function
B2_CreateWheelJointWithDefinition
bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, &def?
Create wheel joint.
function
B2_CreateWheelJointWithDefinition_v
bodyA, bodyB, anchor#[], axis#[], &def?
Create wheel joint.
procedure
B2_WheelJointEnableMotor
joint, value
Enable/disable motor for wheel joint.
function
B2_WheelJointJointSpeed#
joint
Get joint translation speed for wheel joint.
function
B2_WheelJointJointTranslation#
joint
Get current joint translation for wheel joint.
function
B2_WheelJointMaxMotorTorque#
joint
Get max motor torque for wheel joint.
function
B2_WheelJointMotorSpeed#
joint
Get motor speed for wheel joint.
function
B2_WheelJointMotorTorque#
joint, inv_dt#
Get current motor torque given the inverse time step for wheel joint.
procedure
B2_WheelJointSetMaxMotorTorque
joint, torque#
Set max motor torque for wheel joint.
procedure
B2_WheelJointSetMotorSpeed
joint, speed#
Set motor speed for wheel joint.
function
B2_WheelJointMotorEnabled
joint
Return true if motor is enabled for wheel joint.
function
B2_JointBodyA
joint
Get joint's first body.
function
B2_JointBodyB
joint
Get joint's second body.
function
B2_JointAnchorA#[]
joint
Get joint's first anchor position in world coordinates.
function
B2_JointAnchorB#[]
joint
Get joint's second anchor position in world coordinates.
procedure
B2_DestroyJoint
joint
Destroy joint.

Contacts

Name
Parameters
Brief description
function
B2_Contacts?[]
Get list of all contacts in world.
function
B2_BodyContacts?[]
body
Get list of all contacts involving specific body.
procedure
B2_IterateContacts
Start iteration of all contacts in world.
procedure
B2_BodyIterateContacts
body
Start iteration of all contacts for specific body.
function
B2_NextContact
&contact?
Get next contact.

Helper functions

Name
Parameters
Brief description
function
B2H_OpenWindow
title$, x, y, w, h, hideNaaLaa
Init helper.
procedure
B2H_Update
timeStep#
Update Box2D and OpenGL.
procedure
B2H_Flush
Flush graphics to window.
procedure
B2H_SetCameraView
x#, y#, zoom#
Set and use camera view.
procedure
B2H_SetNormalView
Set normal view.
function
B2H_Width
Get window width.
function
B2H_Height
Get window height.
procedure
B2H_ClearScreen
r, g, b
Clear screen.
procedure
B2H_DrawLine
x1, y1, x2, y2
Draw line.
procedure
B2H_DrawLine_v
a[], b[]
Draw line.
procedure
B2H_DrawLineF
x1#, y1#, x2#, y2#
Draw line with float coordinates.
procedure
B2H_DrawLineF_v
a#[], b#[]
Draw line with float coordinates.
procedure
B2H_LoadImage
img, filename$
Load image and create texture.
procedure
B2H_FreeImage
img
Free image and texture.
procedure
B2H_DrawImage
img, x, y, cel
Draw image.
procedure
B2H_LoadFont
index, filename$
Load single file font.
procedure
B2H_Write
fontIndex, x, y, txt$
Write string.
procedure
B2H_WriteRight
fontIndex, x, y, txt$
Write string right justified.
procedure
B2H_Center
fontIndex, x, y, txt$
Write string centered.
procedure
B2H_DrawRect
x, y, w, h, filled
Draw rectangle.
procedure
B2H_SetRGB
r, g, b
Set color.
procedure
B2H_SetRGBA
r, g, b, a
Set color.
function
B2H_CreateBox?
type, x#, y#, w#, h#, angle#, density#, friction#, restitution#
Create box object.
function
B2H_CreateCircle?
type, x#, y#, radius#, density#, friction#, restitution#
Create circle object.
function
B2H_CreatePolygon?
type, x#, y#, vertices#[][], density#, friction#, restitution#
Create polygon object.
function
B2H_CreateChain?
type, x#, y#, vertices#[][], density#, friction#, restitution#
Create chain object.
function
B2H_CreateBillboard?
img, x#, y#, w#, h#, a#
Create billboard object.
function
B2H_BillboardPosition#[]
&obj?
Return billboard position.
function
B2H_BillboardAngle#
&obj?
Return billboard angle.
function
B2H_BillboardScaleX#
&obj?
Return billboard x scale.
function
B2H_BillboardScaleY#
&obj?
Return billboard y scale.
procedure
B2H_BillboardSetPosition
&obj?, x#, y#
Set billboard position.
procedure
B2H_BillboardSetAngle
&obj?, angle#
Set billboard angle.
procedure
B2H_BillboardSetScale
&obj?, sx#, sy#
Set billboard scale.
procedure
B2H_ResetObject
&obj?
Reset position, angle and velocities of object.
procedure
B2H_DestroyObject
&obj?
Destroy object.
procedure
B2H_SetObjectImage
&obj?, img
Set object image.
procedure
B2H_DrawObject
&obj?
Draw object.
function
B2H_ToWorld#[]
x#, y#
Convert from screen to world coordinates.
function
B2H_ToWorldX#
x#
Convert screen x to world coordinate.
function
B2H_ToWorldY#
y#
Convert screen y to world coordinate.


Subroutine documentation

function B2_Init ( x#, y# )

Initialize and create world. There can only be one world. For normal gravity, set 'x' to 0 and 'y' to -10.

Parameter
Mode
Description
x
In
Gravity vector x component.
y
In
Gravity vector y component.

Return value
True on success.

[ Back ]


procedure B2_SetVelocityIterations ( velocityIterations )

You may experiment with this. The Box2D documentation states that 8 (default) is a good number.

Parameter
Mode
Description
velocityIterations
In
Velocity iteration count.

[ Back ]


procedure B2_SetPositionIterations ( positionIterations )

You may experiment with this. The Box2D documentation states that 3 (default) is a good number.

Parameter
Mode
Description
positionIterations
In
Position iteration count.

[ Back ]


procedure B2_Step ( timeStep# )

You need to call this once per update frame. In general, you should pass the inverted FPS (frames per second) value of your program, like 1.0/60.0.

Parameter
Mode
Description
timeStep
In
Time step.

[ Back ]


function B2_CreateBody ( type, x#, y# )

Parameter
Mode
Description
type
In
Type of body: B2_STATIC_BODY, B2_KINEMATIC_BODY or B2_DYNAMIC_BODY.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Body handle.

[ Back ]


procedure B2_DestroyBody ( body )

Destroy body. This will also destroy all fixtures attached to the body.

Parameter
Mode
Description
body
In
Body handle.

[ Back ]


function B2_CreateBodyWithDefinition ( &def? )

Create body from definition. This definition represents the b2BodyDef struct. These are the fields (all optional) that you can set.

  type (B2_STATIC_BODY, B2_KINEMATIC_BODY, B2_DYNAMIC_BODY)
  x# (position)
  y# (position)
  active
  allowSleep
  angle#
  angularDamping#
  angularVelocity#
  awake
  bullet
  fixedRotation
  gravityScale#
  linearDamping#
  linearVelocityX#
  linearVelocityY#

Parameter
Mode
Description
def
In
Body definition.

Return value
Body handle.

[ Back ]


function B2_BodyPosition#[] ( body )

Get body's position.

Parameter
Mode
Description
body
In
Body handle

Return value
Position [x, y].

[ Back ]


function B2_BodyAngle# ( body )

Get body's angle.

Parameter
Mode
Description
body
In
Body handle.

Return value
Angle.

[ Back ]


procedure B2_BodySetTransform ( body, x#, y#, a# )

Set body's position and angle.

Parameter
Mode
Description
body
In
Body handle.
x
In
X coordinate.
y
In
Y coordinate.
a
In
Angle.

[ Back ]


function B2_BodyActive ( body )

Return true if body is active.

Parameter
Mode
Description
body
In
Body handle.

Return value
True if body is active.

[ Back ]


procedure B2_BodySetActive ( body, value )

Set body active flag.

Parameter
Mode
Description
body
In
Body handle.
value
In
Value (true or false).

[ Back ]


function B2_BodyAwake ( body )

Return true if body is awake.

Parameter
Mode
Description
body
In
Body handle.

Return value
True if body is awake.

[ Back ]


procedure B2_BodySetAwake ( body, value )

Set body awake flag.

Parameter
Mode
Description
body
In
Body handle.
value
In
Value (true or false).

[ Back ]


function B2_BodyBullet ( body )

Return true if body is bullet.

Parameter
Mode
Description
body
In
Body handle.

Return value
True if body is bullet.

[ Back ]


procedure B2_BodySetBullet ( body, value )

Set body bullet flag.

Parameter
Mode
Description
body
In
Body handle.
value
In
Value (true or false).

[ Back ]


function B2_BodyFixedRotation ( body )

Return true if body has fixed rotation.

Parameter
Mode
Description
body
In
Body handle.

Return value
True if body has fixed rotation.

[ Back ]


procedure B2_BodySetFixedRotation ( body, value )

Set body fixed rotation flag.

Parameter
Mode
Description
body
In
Body handle.
value
In
Value (true or false).

[ Back ]


function B2_BodySleepingAllowed ( body )

Return true if sleeping is allowed for body .

Parameter
Mode
Description
body
In
Body handle.

Return value
True if sleeping is allowed for body.

[ Back ]


procedure B2_BodySetSleepingAllowed ( body, value )

Set body sleeping allowed flag.

Parameter
Mode
Description
body
In
Body handle.
value
In
Value (true or false).

[ Back ]


function B2_BodyLinearVelocity#[] ( body )

Get body's linear velocity.

Parameter
Mode
Description
body
In
Body handle.

Return value
Velocity vector [x, y].

[ Back ]


procedure B2_BodySetLinearVelocity ( body, x#, y# )

Set body's linear velocity.

Parameter
Mode
Description
body
In
Body handle.
x
In
X component of vector.
y
In
Y component of vector.

[ Back ]


function B2_BodyAngularVelocity# ( body )

Get body's angular velocity.

Parameter
Mode
Description
body
In
Body handle.

Return value
Angular velocity.

[ Back ]


procedure B2_BodySetAngularVelocity ( body, v# )

Set body's angular velocity.

Parameter
Mode
Description
body
In
Body handle
v
In
Angular velocity.

[ Back ]


function B2_BodyLinearDamping# ( body )

Get body's linear damping.

Parameter
Mode
Description
body
In
Body handle.

Return value
Linear damping.

[ Back ]


procedure B2_BodySetLinearDamping ( body, d# )

Set body's linear damping.

Parameter
Mode
Description
body
In
Body handle.
d
In
Linear damping.

[ Back ]


function B2_BodyAngularDamping# ( body )

Get body's angular damping.

Parameter
Mode
Description
body
In
Body handle.

Return value
Angular damping.

[ Back ]


procedure B2_BodySetAngularDamping ( body, d# )

Set body's angular damping.

Parameter
Mode
Description
body
In
Body handle.
d
In
Angular damping.

[ Back ]


procedure B2_BodyApplyForce ( body, forceX#, forceY#, pointX#, pointY# )

Apply force to body.

Parameter
Mode
Description
body
In
Body handle.
forceX
In
X component of force vector.
forceY
In
Y component of force vector.
pointX
In
X component of source point.
pointY
In
Y component of source point.

[ Back ]


procedure B2_BodyApplyForce_v ( body, force#[], point#[] )

Apply force to body.

Parameter
Mode
Description
body
In
Body handle.
force
In
Force vector, [x, y].
point
In
Source point, [x, y].

[ Back ]


procedure B2_BodyApplyTorque ( body, torque# )

Apply toque to body.

Parameter
Mode
Description
body
In
Body handle.
torque
In
Torque.

[ Back ]


procedure B2_BodyApplyLinearImpulse ( body, impulseX#, impulseY#, pointX#, pointY# )

Apply linear impulse to body.

Parameter
Mode
Description
body
In
Body handle.
impulseX
In
X component of impulse vector.
impulseY
In
Y component of impulse vector.
pointX
In
X component of source point.
pointY
In
Y component of source point.

[ Back ]


procedure B2_BodyApplyLinearImpulse_v ( body, impulse#[], point#[] )

Apply linear impulse to body.

Parameter
Mode
Description
body
In
Body handle.
impulse
In
Impulse vector.
point
In
Source point.

[ Back ]


procedure B2_BodyApplyAngularImpulse ( body, impulse# )

Apply angular impulse to body.

Parameter
Mode
Description
body
In
Body handle.
impulse
In
Impulse.

[ Back ]


procedure B2_BodyDestroyFixture ( body, fixture )

Destroy fixture.

Parameter
Mode
Description
body
In
Body handle.
fixture
In
Fixture handle.

[ Back ]


function B2_BodyWorldCenter#[] ( body )

Get world center point.

Parameter
Mode
Description
body
In
Body handle.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyLocalCenter#[] ( body )

Get local center point.

Parameter
Mode
Description
body
In
Body handle.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyWorldPoint#[] ( body, x#, y# )

Get world point from local.

Parameter
Mode
Description
body
In
Body handle.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyLocalPoint#[] ( body, x#, y# )

Get local point from world.

Parameter
Mode
Description
body
In
Body handle.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyWorldVector#[] ( body, x#, y# )

Get world vector from local.

Parameter
Mode
Description
body
In
Body handle.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyLocalVector#[] ( body, x#, y# )

Get local vector from world.

Parameter
Mode
Description
body
In
Body handle.
x
In
X coordinate.
y
In
Y coordinate.

Return value
Coordinates, [x, y].

[ Back ]


function B2_BodyMass# ( body )

Get body mass.

Parameter
Mode
Description
body
In
Body handle

Return value
Mass.

[ Back ]


function B2_CreateCircleShape ( x#, y#, r# )

Create circle shape.

Parameter
Mode
Description
x
In
X coordinate.
y
In
Y coordinate.
r
In
Radius.

Return value
Shape handle.

[ Back ]


function B2_CreateBoxShape ( hx#, hy# )

Create box shape.

Parameter
Mode
Description
hx
In
Half length in x.
hy
In
Half length in y.

Return value
Shape handle.

[ Back ]


function B2_CreateBoxShape2 ( hx#, hy#, cx#, cy#, a# )

Create box shape.

Parameter
Mode
Description
hx
In
Half length in x.
hy
In
Half length in y.
cx
In
Center x.
cy
In
Center y.
a
In
Angle.

Return value
Shape handle.

[ Back ]


function B2_CreatePolygonShape ( vertices#[][] )

Create polygon chape from vertices. The polygon must be convex, and the vertices should be listed counter clockwise order (in regard to the Box2D coordinate system, y up, x right, z out from the screen). The maximum number of vertices are set by Box2D to 8.

Parameter
Mode
Description
vertices
In
Vertices.

Return value
Shape handle.

[ Back ]


function B2_CreateChainShape ( vertices#[][] )

Create chain chape from vertices.

Parameter
Mode
Description
vertices
In
Vertices.

Return value
Shape handle.

[ Back ]


function B2_ShapeVertex#[] ( shape, index )

This only makes sense for polygons and chains.

Parameter
Mode
Description
shape
In
Shape handle.
index
In
Vertex index.

Return value
Vertex [x, y]

[ Back ]


procedure B2_DestroyShape ( shape )

Destroy shape.

Parameter
Mode
Description
shape
In
Shape handle.

[ Back ]


function B2_CreateFixture ( body, shape, density#, releaseShape )

Create fixture with default fixture material. Unless you want to reuse the shape for some other construction, you should set the last parameter to true.

Parameter
Mode
Description
body
In
Body handle.
shape
In
Shape handle.
density
In
Density.
releaseShape
In
True to release shape.

Return value

[ Back ]


function B2_CreateFixtureWithDefinition ( body, shape, &def?, releaseShape )

Create fixture from definition. This definition represents the b2FixtureDef struct. These are the fields (all optional) that you can set.

  density#
  filterCategoryBits (equals filter.categoryBits)
  filterMaskBits (equals filter.maskBits)
  filterGroupIndex (equals filter.groupIndex)
  friction#
  isSensor
  restitution#

Parameter
Mode
Description
body
In
Body handle.
shape
In
Shape handle.
def
In
Fixture definition.

Return value
Fixture handle.

[ Back ]


function B2_CreateDistanceJoint ( bodyA, bodyB, anchorAX#, anchorAY#, anchorBX#, anchorBY#, collideConnected, frequencyHz#, dampingRatio# )

The distance joint can be made "soft". Experiment with the frequencyHz and dampingRatio parameters.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
ax
In
First body anchor world x coordinate.
ay
In
First body anchor world y coordinate.
bx
In
Second body anchor world x coordinate.
by
In
Second body anchor world y coordinate.
collideConnected
In
True if bodies may collide.
frequencyHz
In
Should be less than half the frequency of the time step (usually < 30). (Default 0.)
dampingRatio
In
Should be in the range [0..1], can be higher. (Default 0.)

Return value
Joint handle.

[ Back ]


function B2_CreateDistanceJoint_v ( bodyA, bodyB, anchorA#[], anchorB#[], collideConnected, frequencyHz#, dampingRatio# )

The distance joint can be made "soft". Experiment with the frequencyHz and dampingRatio parameters.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
anchorA
In
First body anchor world position.
anchorB
In
Second body anchor world position.
collideConnected
In
True if bodies may collide.
frequencyHz
In
Should be less than half the frequency of the time step (usually < 30). (Default 0.)
dampingRatio
In
Should be in the range [0..1], can be higher. (Default 0.)

Return value
Joint handle.

[ Back ]


function B2_CreateDistanceJointWC ( bodyA, bodyB, collideConnected, frequencyHz#, dampingRatio# )

The distance joint can be made "soft". Experiment with the frequencyHz and dampingRatio parameters.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
collideConnected
In
True if bodies may collide.
frequencyHz
In
Should be less than half the frequency of the time step (usually < 30). (Default 0.)
dampingRatio
In
Should be in the range [0..1], can be higher. (Default 0.)

Return value
Joint handle.

[ Back ]


function B2_CreateRevoluteJoint ( bodyA, bodyB, anchorX#, anchorY#, collideConnected )

Create revolute joint.

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchorX
In
Anchor world x coordinate.
anchorY
In
Anchor world y coordinate.
collideConnected
In
True if bodies may collide.

Return value
Joint handle.

[ Back ]


function B2_CreateRevoluteJoint_v ( bodyA, bodyB, anchor#[], collideConnected )

Create revolute joint.

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchor
In
Anchor world position.
collideConnected
In
True if bodies may collide.

Return value
Joint handle.

[ Back ]


function B2_RevoluteJointJointAngle# ( joint )

Get joint angle for revolute joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Angle.

[ Back ]


function B2_RevoluteJointJointSpeed# ( joint )

Get joint speed for revolute joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Speed.

[ Back ]


function B2_RevoluteJointMotorTorque# ( joint, inv_dt# )

Get motor torque for revolute joint given the inverse time step.

Parameter
Mode
Description
joint
In
Joint handle.
inv_dt
In
Inverse time step.

Return value
Torque.

[ Back ]


procedure B2_RevoluteJointSetMotorSpeed ( joint, speed# )

Set motor speed for revolute joint.

Parameter
Mode
Description
joint
In
Joint handle.
speed
In
Speed.

[ Back ]


procedure B2_RevoluteJointSetMaxMotorTorque ( joint, torque# )

Set max motor torque for revolute joint.

Parameter
Mode
Description
joint
In
Joint handle.
torque
In
Max torque.

[ Back ]


function B2_CreatePrismaticJoint ( bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, collideConnected )

Create prismatic joint.

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchorX
In
Anchor world x coordinate.
anchorY
In
Anchor world y coordinate.
axisX
In
Axis vector x component.
axisY
In
Axis vector y component.
collideConnected
In
True if bodies may collide.

Return value
Joint handle.

[ Back ]


function B2_CreatePrismaticJoint_v ( bodyA, bodyB, anchor#[], axis#[], collideConnected )

Create prismatic joint.

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchor
In
World position.
axis
In
Axis vector.
collideConnected
In
True if bodies may collide.

Return value
Joint handle.

[ Back ]


function B2_CreatePrismaticJointWithDefinition ( bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, &def? )

Create prismatic joint from definition. This definition represents the b2PrismaticJointDef struct. These are the fields (all optional) that you can set.

  collideConnected True if bodyA can collide with bodyB
  enableLimit Flag to enable joint limits
  enableMotor Flag to enable the joint motor
  lowerTranslation# The lower translation limit
  maxMotorForce# The maximum motor force
  motorSpeed# The desired motor speed, usually in radians per second
  referenceAngle# The constrained angle between the bodies: bodyB_angle - bodyA_angle
  upperTranslation# The upper translation limit

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchorX
In
Anchor world x coordinate.
anchorY
In
Anchor world y coordinate.
axisX
In
Axis vector x component.
axisY
In
Axis vector y component.
def
In
Joint definition.

Return value
Joint handle.

[ Back ]


function B2_CreatePrismaticJointWithDefinition_v ( bodyA, bodyB, anchor#[], axis#[], &def? )

Create prismatic joint from definition. This definition represents the b2PrismaticJointDef struct. These are the fields (all optional) that you can set.

  collideConnected True if bodyA can collide with bodyB
  enableLimit Flag to enable joint limits
  enableMotor Flag to enable the joint motor
  lowerTranslation# The lower translation limit
  maxMotorForce# The maximum motor force
  motorSpeed# The desired motor speed, usually in radians per second
  referenceAngle# The constrained angle between the bodies: bodyB_angle - bodyA_angle
  upperTranslation# The upper translation limit

Parameter
Mode
Description
bodyA
In
First body
bodyB
In
Second body.
anchor
In
Anchor world position.
axis
In
Axis vector.
def
In
Joint definition.

Return value
Joint handle.

[ Back ]


function B2_PrismaticJointJointTranslation# ( joint )

Get joint translation of prismatic joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Translation.

[ Back ]


function B2_PrismaticJointJointSpeed# ( joint )

Get joint translation speed of prismatic joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Speed.

[ Back ]


function B2_PrismaticJointMotorForce# ( joint, inv_dt# )

Get current motor force for prismatic joint given the inverse time step.

Parameter
Mode
Description
joint
In
Joint handle.
inv_dt
In
Inverse time step.

Return value
Force.

[ Back ]


procedure B2_PrismaticJointSetMotorSpeed ( joint, speed# )

Set motor speed for prismatic joint.

Parameter
Mode
Description
joint
In
Joint handle.
speed
In
Speed.

[ Back ]


procedure B2_PrismaticJointSetMaxMotorForce ( joint, force# )

Set the maximum motor force for prismatic joint.

Parameter
Mode
Description
joint
In
Joint handle.
force
In
Max force.

[ Back ]


function B2_CreatePulleyJoint_v ( bodyA, bodyB, groundAnchorA#[], groundAnchorB#[], anchorA#[], anchorB#[], ratio#, collideConnected )

Create pulley joint.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
groundAnchorA
In
First ground anchor world position.
groundAnchorB
In
Second ground anchor world position.
anchorA
In
First anchor world position.
anchorB
In
Second anchor world position.
ratio
In
Pulley ratio, used to simulate a block-and-tackle.
collideConnected
In
True if the bodies may collide.

Return value
Joint handle.

[ Back ]


function B2_PulleyJointGroundAnchorA#[] ( joint )

Get first ground anchor's woorld position of pulley joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Position, [x, y].

[ Back ]


function B2_PulleyJointGroundAnchorB#[] ( joint )

Get second ground anchor's woorld position of pulley joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Position, [x, y].

[ Back ]


function B2_PulleyJointLengthA# ( joint )

Get length between first anchor and ground anchor of pulley joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Length.

[ Back ]


function B2_PulleyJointLengthB# ( joint )

Get length between second anchor and ground anchor of pulley joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Length.

[ Back ]


function B2_PulleyJointRatio# ( joint )

Get joint pulley ratio.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Ratio.

[ Back ]


function B2_CreateWheelJoint ( bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY# )

A wheel joint restricts a point on bodyB to a line on bodyA.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
anchorX
In
Anchor world x coordinate.
anchorY
In
Anchor world y coordinate.
axisX
In
Axis vector x coordinate.
axisY
In
Axis vector y coordinate.

Return value

[ Back ]


function B2_CreateWheelJoint_v ( bodyA, bodyB, anchor#[], axis#[] )

A wheel joint restricts a point on bodyB to a line on bodyA.

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
anchor
In
Anchor world position.
axis
In
Axis vector.

Return value

[ Back ]


function B2_CreateWheelJointWithDefinition ( bodyA, bodyB, anchorX#, anchorY#, axisX#, axisY#, &def? )

A wheel joint restricts a point on bodyB to a line on bodyA. The definition object represents the b2WheelJointDef struct. These are the fields (all optional) that you can set.

  collideConnected True if bodyA can collide with bodyB
  dampingRatio Suspension damping ratio, one indicates critical damping
  enableMotor Flag to enable the joint motor
  frequencyHz# Suspension frequency, zero indicates no suspension
  maxMotorTorque# The maximum motor torque
  motorSpeed# The desired motor speed, usually in radians per second

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
anchorX
In
Anchor world x coordinate.
anchorY
In
Anchor world y coordinate.
axisX
In
Axis vector x coordinate.
axisY
In
Axis vector y coordinate.
def
In
Joint definition.

Return value

[ Back ]


function B2_CreateWheelJointWithDefinition_v ( bodyA, bodyB, anchor#[], axis#[], &def? )

A wheel joint restricts a point on bodyB to a line on bodyA. The definition object represents the b2WheelJointDef struct. These are the fields (all optional) that you can set.

  collideConnected True if bodyA can collide with bodyB
  dampingRatio Suspension damping ratio, one indicates critical damping
  enableMotor Flag to enable the joint motor
  frequencyHz# Suspension frequency, zero indicates no suspension
  maxMotorTorque# The maximum motor torque
  motorSpeed# The desired motor speed, usually in radians per second

Parameter
Mode
Description
bodyA
In
First body handle.
bodyB
In
Second body handle.
anchor
In
Anchor world position.
axis
In
Axis vector.
def
In
Joint definition.

Return value

[ Back ]


procedure B2_WheelJointEnableMotor ( joint, value )

Enable/disable motor for wheel joint.

Parameter
Mode
Description
value
In
True or false.

[ Back ]


function B2_WheelJointJointSpeed# ( joint )

Get joint translation speed for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
speed.

[ Back ]


function B2_WheelJointJointTranslation# ( joint )

Get current joint translation for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Translation.

[ Back ]


function B2_WheelJointMaxMotorTorque# ( joint )

Get max motor torque for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Torque.

[ Back ]


function B2_WheelJointMotorSpeed# ( joint )

Get motor speed for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
speed.

[ Back ]


function B2_WheelJointMotorTorque# ( joint, inv_dt# )

Get current motor torque given the inverse time step for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.
inv_dt
In
Inverse time step.

Return value
Torque.

[ Back ]


procedure B2_WheelJointSetMaxMotorTorque ( joint, torque# )

Set max motor torque for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.
torque
In
Torque.

[ Back ]


procedure B2_WheelJointSetMotorSpeed ( joint, speed# )

Set motor speed for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.
speed
In
Speed.

[ Back ]


function B2_WheelJointMotorEnabled ( joint )

Return true if motor is enabled for wheel joint.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
True if motor is enabled.

[ Back ]


function B2_JointBodyA ( joint )

Get joint's first body.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Body handle.

[ Back ]


function B2_JointBodyB ( joint )

Get joint's second body.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Body handle.

[ Back ]


function B2_JointAnchorA#[] ( joint )

Get joint's first anchor position in world coordinates.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Anchor position, [x, y].

[ Back ]


function B2_JointAnchorB#[] ( joint )

Get joint's second anchor position in world coordinates.

Parameter
Mode
Description
joint
In
Joint handle.

Return value
Anchor position, [x, y].

[ Back ]


procedure B2_DestroyJoint ( joint )

Joints are automaticly destroyed when any of the involved bodies are.

Parameter
Mode
Description
joint
In
Joint handle.

[ Back ]


function B2_Contacts?[] ( )

Get list of all contacts in world. These are the fields of each object:

  ba - Body A handle
  fa - Fixture A handle (belongs to body A)
  bb - Body B handle
  fb - Fixture B handle (belongs to body B)

Return value
Contact list.

[ Back ]


function B2_BodyContacts?[] ( body )

Get list of all contacts involving specific body. These are the fields of each object:

  ba - Body A handle
  fa - Fixture A handle (belongs to body A)
  bb - Body B handle
  fb - Fixture B handle (belongs to body B)

Note that ba is always the body handle that was passed to the function.

Parameter
Mode
Description
body
In
Body handle.

Return value
Contact list.

[ Back ]


procedure B2_IterateContacts ( )

Start iteration of all contacts in the world. After calling this procedure, you can call B2_NextContact until it returns false to get one contact at the time.

[ Back ]


procedure B2_BodyIterateContacts ( body )

Start iteration of all contacts for specific body. After calling this procedure, you can call B2_NextContact until it returns false to get one contact at the time.

Parameter
Mode
Description
body
In
Body handle.

[ Back ]


function B2_NextContact ( &contact? )

Get next contact. Use this function after calling B2_IterateContacts or B2_BodyIterateContacts. You can keep calling it until it returns false. The object reference parameter will contain the following fields if the function returns true:

  ba - Body A handle
  fa - Fixture A handle (belongs to body A)
  bb - Body B handle
  fb - Fixture B handle (belongs to body B)

Parameter
Mode
Description
contact
In
Returned contact information.

Return value
True as long as a contact exists.

[ Back ]


function B2H_OpenWindow ( title$, x, y, w, h, hideNaaLaa )

Initializes helper and creates an OpenGL window.

Parameter
Mode
Description
title
In
Window title.
x
In
Window x coordinate.
y
In
Window y coordinate.
w
In
Window width.
h
In
Window height.
hideNaaLaa
In
True for hiding the NaaLaa window.

Return value
True on success.

[ Back ]


procedure B2H_Update ( timeStep# )

This function replaces B2_Update and glUpdate, so don't call any of those two when using this.

Parameter
Mode
Description
timeStep
In
Time step, usually 1.0/FPS.

[ Back ]


procedure B2H_Flush ( )

Flush graphics to window. Use instead of NaaLaa's redraw command. This is the same thing as calling glRender.

[ Back ]


procedure B2H_SetCameraView ( x#, y#, zoom# )

Call this before drawing your objects.

Parameter
Mode
Description
x
In
Camera center x coordinate.
y
In
Camera center y coordinate.
zoom
In
Zoom factor.

[ Back ]


procedure B2H_SetNormalView ( )

Call this before drawing normaly.

[ Back ]


function B2H_Width ( )

Get window width.

Return value
Window width.

[ Back ]


function B2H_Height ( )

Get window height.

Return value
Window height.

[ Back ]


procedure B2H_ClearScreen ( r, g, b )

Clear screen.

Parameter
Mode
Description
r
In
Red color component.
g
In
Green color component.
b
In
Blue color component.

[ Back ]


procedure B2H_DrawLine ( x1, y1, x2, y2 )

Draw line.

Parameter
Mode
Description
x1
In
First point x coordinate.
y1
In
First point y coordinate.
x2
In
Second point x coordinate.
y2
In
Second point y coordinate.

[ Back ]


procedure B2H_DrawLine_v ( a[], b[] )

Draw line.

Parameter
Mode
Description
a
In
First point.
b
In
Second point.

[ Back ]


procedure B2H_DrawLineF ( x1#, y1#, x2#, y2# )

Draw line with float coordinates.

Parameter
Mode
Description
x1
In
First point x coordinate.
y1
In
First point y coordinate.
x2
In
Second point x coordinate.
y2
In
Second point y coordinate.

[ Back ]


procedure B2H_DrawLineF_v ( a#[], b#[] )

Draw line with float coordinates.

Parameter
Mode
Description
a
In
First point.
b
In
Second point.

[ Back ]


procedure B2H_LoadImage ( img, filename$ )

Load image and create texture.

Parameter
Mode
Description
img
In
Image id.
filename
In
Filename.

[ Back ]


procedure B2H_FreeImage ( img )

Free image and texture.

Parameter
Mode
Description
img
In
Image id.

[ Back ]


procedure B2H_DrawImage ( img, x, y, cel )

Draw image. The image must have an OpenGL texture.

Parameter
Mode
Description
img
In
Image id.
x
In
X coordinate.
y
In
Y coordinate.
cel
In
Image cel.

[ Back ]


procedure B2H_LoadFont ( index, filename$ )

Load NaaLaa font from single file.

Parameter
Mode
Description
index
In
Font index [0..?]
filename
In
Filename.

[ Back ]


procedure B2H_Write ( fontIndex, x, y, txt$ )

Write string.

Parameter
Mode
Description
fontIndex
In
Font index.
x
In
X coordinate.
y
In
Y coordinate.
txt
In
Text.

[ Back ]


procedure B2H_WriteRight ( fontIndex, x, y, txt$ )

Write string right justified.

Parameter
Mode
Description
fontIndex
In
Font index.
x
In
X coordinate.
y
In
Y coordinate.
txt
In
Text.

[ Back ]


procedure B2H_Center ( fontIndex, x, y, txt$ )

Write string centered.

Parameter
Mode
Description
fontIndex
In
Font index.
x
In
X coordinate.
y
In
Y coordinate.
txt
In
Text.

[ Back ]


procedure B2H_DrawRect ( x, y, w, h, filled )

Draw rectangle.

Parameter
Mode
Description
x
In
X coordinate.
y
In
Y coordinate.
w
In
Width.
h
In
Height.
filled
In
True for a filled rectangle.

[ Back ]


procedure B2H_SetRGB ( r, g, b )

Set color.

Parameter
Mode
Description
r
In
Red component.
g
In
Green component.
b
In
Blue component.

[ Back ]


procedure B2H_SetRGBA ( r, g, b, a )

Set color.

Parameter
Mode
Description
r
In
Red component.
g
In
Green component.
b
In
Blue component.
a
In
Alpha component.

[ Back ]


function B2H_CreateBox? ( type, x#, y#, w#, h#, angle#, density#, friction#, restitution# )

These are the object fields you may need to access:
  b Body handle.
  f Fixture handle.

Parameter
Mode
Description
type
In
Type, B2_STATIC_BODY, B2_KINEMATIC_BODY or B2_DYNAMIC_BODY.
x
In
Position x coordinate.
y
In
Position y coordinate.
w
In
Width.
h
In
Height.
angle
In
Angle.
density
In
Density.
friction
In
Friction.
restitution
In
Restitution.

Return value
Object handle.

[ Back ]


function B2H_CreateCircle? ( type, x#, y#, radius#, density#, friction#, restitution# )

These are the object fields you may need to access:
  b Body handle.
  f Fixture handle.

Parameter
Mode
Description
type
In
Type, B2_STATIC_BODY, B2_KINEMATIC_BODY or B2_DYNAMIC_BODY.
x
In
Position x coordinate.
y
In
Position y coordinate.
radius
In
Radius.
density
In
Density.
friction
In
Friction.
restitution
In
Restitution.

Return value
Object handle.

[ Back ]


function B2H_CreatePolygon? ( type, x#, y#, vertices#[][], density#, friction#, restitution# )

These are the object fields you may need to access:
  b Body handle.
  f Fixture handle.
  s Shape.

Parameter
Mode
Description
type
In
Type, B2_STATIC_BODY, B2_KINEMATIC_BODY or B2_DYNAMIC_BODY.
x
In
Position x coordinate.
y
In
Position y coordinate.
vertices
In
Vertices.
density
In
Density.
friction
In
Friction.
restitution
In
Restitution.

Return value
Object handle.

[ Back ]


function B2H_CreateChain? ( type, x#, y#, vertices#[][], density#, friction#, restitution# )

These are the object fields you may need to access:
  b Body handle.
  f Fixture handle.
  s Shape.

Parameter
Mode
Description
type
In
Type, B2_STATIC_BODY, B2_KINEMATIC_BODY or B2_DYNAMIC_BODY.
x
In
Position x coordinate.
y
In
Position y coordinate.
vertices
In
Vertices.
density
In
Density.
friction
In
Friction.
restitution
In
Restitution.

Return value
Object handle.

[ Back ]


function B2H_CreateBillboard? ( img, x#, y#, w#, h#, a# )

Create billboard object. This is just an image, not a physics object.

Parameter
Mode
Description
img
In
Image id.
x
In
Center x coordinate.
y
In
Center y coordinate.
w
In
Width.
h
In
Height.
a
In
Angle.

Return value
Object handle.

[ Back ]


function B2H_BillboardPosition#[] ( &obj? )

Return billboard position.

Parameter
Mode
Description
obj
In
Object handle.

Return value
Position, [x, y].

[ Back ]


function B2H_BillboardAngle# ( &obj? )

Return billboard angle.

Parameter
Mode
Description
obj
In
Object handle.

Return value
Angle.

[ Back ]


function B2H_BillboardScaleX# ( &obj? )

Return billboard x scale.

Parameter
Mode
Description
obj
In
Object handle.

Return value
X scale.

[ Back ]


function B2H_BillboardScaleY# ( &obj? )

Return billboard y scale.

Parameter
Mode
Description
obj
In
Object handle.

Return value
Y scale.

[ Back ]


procedure B2H_BillboardSetPosition ( &obj?, x#, y# )

Set billboard position.

Parameter
Mode
Description
obj
In
Object handle.
x
In
X coordinate.
y
In
Y coordinate.

[ Back ]


procedure B2H_BillboardSetAngle ( &obj?, angle# )

Set billboard angle.

Parameter
Mode
Description
obj
In
Object handle.
angle
In
Angle.

[ Back ]


procedure B2H_BillboardSetScale ( &obj?, sx#, sy# )

Set billboard scale.

Parameter
Mode
Description
obj
In
Object handle.
sx
In
X scale.
sy
In
Y scale.

[ Back ]


procedure B2H_ResetObject ( &obj? )

Reset position, angle and velocities of object.

Parameter
Mode
Description
obj
In
Object handle.

[ Back ]


procedure B2H_DestroyObject ( &obj? )

Destroy object. This will destroy all components of the object.

Parameter
Mode
Description
obj
In
Object handle.

[ Back ]


procedure B2H_SetObjectImage ( &obj?, img )

Set object image. This image needs to have an OpenGL texture. You can either load images normaly and then call glCreateImageTexture, or you can use the B2H_LoadImage function, which automaticly creates textures.

Parameter
Mode
Description
obj
In
Object.
img
In
Image.

[ Back ]


procedure B2H_DrawObject ( &obj? )

Draw object. If object has been assigned an image, the image will be used, else it will be drawn as a polygon.

Parameter
Mode
Description
obj
In
Object.

[ Back ]


function B2H_ToWorld#[] ( x#, y# )

Convert from screen to world coordinates.

Parameter
Mode
Description
x
In
Screen x coordinate.
y
In
Screen y coordinate.

Return value
World coordinates as [x, y].

[ Back ]


function B2H_ToWorldX# ( x# )

Convert screen x to world coordinate.

Parameter
Mode
Description
x
In
Screen x coordinate.

Return value
World x coordinate.

[ Back ]


function B2H_ToWorldY# ( y# )

Convert screen y to world coordinate.

Parameter
Mode
Description
y
In
Screen y coordinate.

Return value
World y coordinate.

[ Back ]


Generated with NLDoc 20141102.