Maarten Baert's website

Game Maker / C++ projects

Home Model Creator ExtremePhysics Game Maker DLLs SimpleScreenRecorder AlterPCB Quadcopters   Recent comments Search

Last modified: Thu, 12 Jul 2012
Refresh

Shape


ep_shape_create_box

ep_shape_create_box(world_id, body_id, w, h, x, y, rot, density)

Creates a new box shape.

Returns the id of the new shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • w: The width of the box.

  • h: The height of the box.

  • x: The x component of the position of the center of the box (local coordinates).

  • y: The y component of the position of the center of the box (local coordinates).

  • rot: The rotation of the box (local coordinates).

  • density: The density of the box.


ep_shape_create_line

ep_shape_create_line(world_id, body_id, x1, y1, x2, y2, density)

Creates a new line shape. This is actually just a rotated box with a height of 0.

Returns the id of the new shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • x1: The x coordinate of the first point (local coordinates).

  • y1: The y coordinate of the first point (local coordinates).

  • x2: The x coordinate of the second point (local coordinates).

  • y2: The y coordinate of the second point (local coordinates).

  • density: The density of the line.


ep_shape_create_circle

ep_shape_create_circle(world_id, body_id, r, x, y, rot, density)

Creates a new circle shape.

Returns the id of the new shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • r: The radius of the circle.

  • x: The x component of the position of the center of the circle (local coordinates).

  • y: The y component of the position of the center of the circle (local coordinates).

  • rot: The rotation of the circle (local coordinates).

  • density: The density of the circle.


ep_shape_create_polygon

ep_shape_create_polygon(world_id, body_id, polygon_id, x, y, rot, density)

Creates a new polygon shape.

Returns the id of the new shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • polygon_id: The id of the polygon.

  • x: The x component of the position of the center of the polygon (local coordinates).

  • y: The y component of the position of the center of the polygon (local coordinates).

  • rot: The rotation of the polygon (local coordinates).

  • density: The density of the circle.


ep_shape_destroy

ep_shape_destroy(world_id, body_id, shape_id)

Destroys the shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_exists

ep_shape_exists(world_id, body_id, shape_id)

Returns whether the shape with the given id exists.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_get_first_contact

ep_shape_get_first_contact(world_id, body_id, shape_id)

Returns the id of the first contact connected to this shape, or 0 if there are no contacts connected to this shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_get_last_contact

ep_shape_get_last_contact(world_id, body_id, shape_id)

Returns the id of the last contact connected to this shape, or 0 if there are no contacts connected to this shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_get_previous_contact

ep_shape_get_previous_contact(world_id, body_id, shape_id, contact_id)

Returns the id of the previous contact connected to this body, or 0 if there is no previous contact.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • contact_id: The id of the contact.


ep_shape_get_next_contact

ep_shape_get_next_contact(world_id, body_id, shape_id, contact_id)

Returns the id of the next contact connected to this body, or 0 if there is no next contact.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • contact_id: The id of the contact.


ep_shape_set_material

ep_shape_set_material(world_id, body_id, shape_id, restitution, friction, normalvelocity, tangentvelocity)

Changes the material of the shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • restitution: The coefficient of restitution.

  • friction: The coefficient of friction.

  • normalvelocity: The normal velocity of the surface. This can be used to make 'bouncy' materials.

  • tangentvelocity: The tangential velocity of the surface. This can be used to simulate moving surfaces, like conveyor belts.


ep_shape_set_collision

ep_shape_set_collision(world_id, body_id, shape_id, collidemask1, collidemask2, group)

Changes the collision settings of the shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • collidemask1: The first collision mask.

  • collidemask2: The second collision mask.

  • group: The group. Use 0 for no group.


ep_shape_collision_test_box

ep_shape_collision_test_box(world_id,body_id,shape_id,w,h,x,y,rot,contact_threshold)

Returns whether the shape collides with a 'virtual' box.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • w: The width of the box.

  • h: The height of the box.

  • x: The x coordinate of the box (world coordinates).

  • y: The y coordinate of the box (world coordinates).

  • rot: The rotation of the box (world coordinates).

  • contact_threshold: The contact threshold.


ep_shape_collision_test_line

ep_shape_collision_test_line(world_id,body_id,shape_id,x1,y1,x2,y2,contact_threshold)

Returns whether the shape collides with a 'virtual' line.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • x1: The x coordinate of the first point (world coordinates).

  • y1: The y coordinate of the first point (world coordinates).

  • x2: The x coordinate of the second point (world coordinates).

  • y2: The y coordinate of the second point (world coordinates).

  • contact_threshold: The contact threshold.


ep_shape_collision_test_circle

ep_shape_collision_test_circle(world_id,body_id,shape_id,r,x,y,contact_threshold)

Returns whether the shape collides with a 'virtual' circle.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • r: The radius of the circle.

  • x: The x coordinate of the circle (world coordinates).

  • y: The y coordinate of the circle (world coordinates).

  • contact_threshold: The contact threshold.


ep_shape_collision_test_polygon

ep_shape_collision_test_polygon(world_id,body_id,shape_id,polygon_id,x,y,rot,contact_threshold)

Returns whether the shape collides with a 'virtual' polygon.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • polygon_id: The id of the polygon.

  • x: The x coordinate of the polygon (world coordinates).

  • y: The x coordinate of the polygon (world coordinates).

  • rot: The rotation of the polygon (world coordinates).

  • contact_threshold: The contact threshold.


ep_shape_ray_cast

ep_shape_ray_cast(world_id,body_id,shape_id,x,y,vx,vy)

Calculates whether a 'virtual' ray intersects the shape.

Returns the distance to the point of intersection, or -1 if there is no intersection.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • x: The x coordinate of the starting point of the ray.

  • y: The y coordinate of the starting point of the ray.

  • vx: The x component of the direction vector of the ray.

  • vy: The y component of the direction vector of the ray.


ep_shape_previous

ep_shape_previous(world_id, body_id, shape_id)

Returns the id of the previous shape, or 0 if there is no previous shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_next

ep_shape_next(world_id, body_id, shape_id)

Returns the id of the next shape, or 0 if there is no next shape.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.


ep_shape_set_uservar

ep_shape_set_uservar(world_id, body_id, shape_id, index, value)

Changes the value of the user variable with the given index.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • index: The index (0-4).

  • value: The new value.


ep_shape_get_uservar

ep_shape_get_uservar(world_id, body_id, shape_id, index)

Returns the value of the user variable with the given index.

  • world_id: The id of the world.

  • body_id: The id of the body.

  • shape_id: The id of the shape.

  • index: The index (0-4).


Comments

Earacher

Comment #1: Wed, 20 Mar 2013, 9:46 (GMT+1, DST)

Quote


Hi maarten,how can I resize the shape dynamically?

Maarten Baert

Administrator

Comment #2: Wed, 20 Mar 2013, 21:13 (GMT+1, DST)

Quote


Quote: Earacher

Hi maarten,how can I resize the shape dynamically?

You can't. You can only delete the shape and create a new one. It's not perfect but it works well enough in most cases.

Earacher

Comment #3: Fri, 24 May 2013, 6:57 (GMT+1, DST)

Quote


Hi Maarten.
How can I get the length of the side of a shape?(width or height)

Maarten Baert

Administrator

Comment #4: Fri, 24 May 2013, 14:57 (GMT+1, DST)

Quote


Quote: Earacher

Hi Maarten.
How can I get the length of the side of a shape?(width or height)

You can't, ExtremePhysics assumes you know these because you set them yourself. If you still need them later, you should save them elsewhere (e.g. using local variables).

You could also use user variables, as long as you only need to save 5 numbers or less.

Last modified: Fri, 24 May 2013, 14:59 (GMT+1, DST)

Earacher

Comment #5: Sat, 27 Jul 2013, 19:38 (GMT+1, DST)

Quote


Hi maarten,Can I mirror a shape without destroy and rebuild it?(Sorry I don't know how to say :(

Earacher

Comment #6: Sun, 25 Aug 2013, 7:22 (GMT+1, DST)

Quote


hi maarten,when i destroy a polygon shape it only deleted one of them,how can i shoot'em up?

var s;
for(s=ep_body_first_shape(global.world,body);s!=0;s=ep_shape_next(global.world,body,s)) { ep_shape_destroy(global.world,body,s);  }  

return an error,now i have no idea. :( help?

Last modified: Sun, 25 Aug 2013, 7:32 (GMT+1, DST)

Maarten Baert

Administrator

Comment #7: Sun, 25 Aug 2013, 16:35 (GMT+1, DST)

Quote


Quote: Earacher

hi maarten,when i destroy a polygon shape it only deleted one of them,how can i shoot'em up?

var s;
for(s=ep_body_first_shape(global.world,body);s!=0;s=ep_shape_next(global.world,body,s)) { ep_shape_destroy(global.world,body,s);  }  

return an error,now i have no idea. :( help?

As soon as you delete the first shape, ep_shape_next will tell you that s doesn't exist anymore (since you just destroyed it). Do it like this:

var s, snext;
for(s=ep_body_first_shape(global.world,body);s!=0;s=snext) {
    snext = ep_shape_next(global.world,body,s);
    ep_shape_destroy(global.world,body,s);
}
Earacher

Comment #8: Sun, 25 Aug 2013, 21:11 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Earacher

hi maarten,when i destroy a polygon shape it only deleted one of them,how can i shoot'em up?

var s;
for(s=ep_body_first_shape(global.world,body);s!=0;s=ep_shape_next(global.world,body,s)) { ep_shape_destroy(global.world,body,s);  }  

return an error,now i have no idea. :( help?

As soon as you delete the first shape, ep_shape_next will tell you that s doesn't exist anymore (since you just destroyed it). Do it like this:

var s, snext;
for(s=ep_body_first_shape(global.world,body);s!=0;s=snext) {
    snext = ep_shape_next(global.world,body,s);
    ep_shape_destroy(global.world,body,s);
}

it worked!thanks!

Lukayson

Comment #9: Wed, 14 Sep 2016, 1:47 (GMT+1, DST)

Quote


hello, tell me please, is ep_shape_create_line faster than ep_shape_create_box? I mean not creating but using shape after. Thank you

Maarten Baert

Administrator

Comment #10: Fri, 16 Sep 2016, 2:17 (GMT+1, DST)

Quote


Quote: Lukayson

hello, tell me please, is ep_shape_create_line faster than ep_shape_create_box? I mean not creating but using shape after. Thank you

It makes no difference, ep_shape_create_line is just there for convenience. It's really a box with a height of zero.

Write a comment