Maarten Baert's website

Game Maker / C++ projects

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

Last modified: Sun, 11 Mar 2018
Refresh

Getting started


What is ExtremePhysics?

ExtremePhysics is a 2D rigid body simulation engine designed for Game Maker. The DLL is written in C++.

ExtremePhysics classes

ExtremePhysics uses a number of classes (types of resources):

  • World: This class connects the other classes. You can create multiple worlds, but most of the time one world is all you need.

  • Polygon: Polygons are used to define the vertices of polygon shapes.

  • Body: A body is the equivalent of an object in Game Maker. Usually every object in Game Maker is associated with one body.

  • Shape: Shapes are used to define the shape of a body. There are three types of shapes: box shapes, circle shapes and polygon shapes. One body can consist of multiple shapes.

  • Force: Forces can be added to bodies to simulate some effects, e.g. a rocket engine.

  • Contact: This is a special class. You can't create or destroy contacts, because contacts are created and destroyed automatically by ExtremePhysics during the simulation when different shapes collide. Contacts can be used to detect collisions.

  • Joints: Joints are used to connect bodies. There are multiple types of joints.

  • View: Views can be used to speed up the simulation for games that use views. Parts of the world that are out of view can be put to sleep to save processing time.

This image shows how the classes are connected:

Image: class-connections.png

Hint

All angles in ExtremePhysics are in radians.

Initializing ExtremePhysics

If you are using the DLL (instead of the extension), you have to initialize ExtremePhysics before you can use it. This isn't very hard:

// If the name of the DLL file is ExtremePhysics.dll,
// this should work:
extremephysics_init();

// If the DLL is not in the working directory,
// you can use this instead:
extremephysics_init("path/to/ExtremePhysics.dll");

Note that the game start event is executed after the create event, therefore it's a good idea to create an empty room (room_gamestart) with one object (obj_gamestart) that executes this code before going to the next room, to make sure this code is executed before anything else.

If you forget to initialize the DLL, you will get an error message when you try to use the scripts ("undefined variable global.define_ep_functionname").

Creating a world

Creating a world is easy:

global.world = ep_world_create();

After creating the world, you should change the settings of the world:

ep_world_set_settings(global.world,1,20,10,0.1,0.5,0,0.5,1);

I will explain the meaning of this code in a separate tutorial.

Creating a static body

There are two kinds of bodies: static and dynamic. Static bodies can move, but their movement isn't influenced by other bodies. The movement of dynamic bodies can be influenced by other bodies (even static bodies). Static bodies are used for things that can not be moved by other bodies (e.g. the ground, walls, platforms that move at a fixed speed).

I will show you how to create a simple static box. First you have to create the body:

body = ep_body_create_static(global.world);
// global.world: the id of the world you created.

However, without any shapes the body isn't very useful. The next step is to add a box shape:

shape1 = ep_shape_create_box(global.world,body,32,32,0,0,0,1);
// global.world: the id of the world.
// body: the id of the body you created.
// 32,32: the size of the box.
// 0,0,0: the relative coordinates of the shape (x,y,rot).
// 1: the density of the box (not used for static bodies).

This code will create a static box, but the box won't collide with anything. The collision system ExtremePhysics uses takes three values: collision mask 1, collision mask 2 and group. Collision mask 1 and collision mask 2 are 32-bit unsigned integers. Collision mask 1 stores the layers the shape belongs to, collision mask 2 stores the layers the shape should collide with. Every bit is one layer, so you can use up to 32 layers. If collision mask 1 matches collision mask 2 or collision mask 2 matches collision mask 1, the bodies will collide. But if they are in the same group (not group 0), they will never collide.

// pseudo-code
if (shape1.mask1 & shape2.mask2 != 0 or shape1.mask2 & shape2.mask1 != 0) and (shape1.group == 0 or shape1.group != shape2.group) {
    // collision
} else {
    // no collision
}

Groups are useful if your game uses lots of small groups of bodies that can't collide, like cars (the wheels shouldn't collide with the car, otherwise they can't overlap).

ep_shape_set_collision(global.world,body,shape1,1,1,0);
// 1: collision mask 1 (binary 00000000 00000000 00000000 00000001).
// 1: collision mask 2 (binary 00000000 00000000 00000000 00000001).
// 0: group (0 means no group).

The next step is to change the material of the box:

ep_shape_set_material(global.world,body,shape1,0.5,0.4,0,0);
// 0.5: coefficient of restitution.
// 0.4: friction.
// 0: normal surface velocity.
// 0: tangential surface velocity.

Finally the box is moved to the correct position:

ep_body_set_position(global.world,body,x,y,degtorad(image_angle));
// x: x coordinate of the body.
// y: y coordinate of the body.
// degtorad(image_angle): rotation of the body, in radians.

Creating a dynamic body

Creating dynamic bodies is almost the same as creating static bodies. There is one extra argument for dynamic bodies: norotation. If norotation is true, the rotation of the body will not be influenced by other bodies (because the moment of inertia of the body is infinite).

body = ep_body_create_dynamic(global.world,false);
// false: this body can rotate.

You have to set the center of mass, mass and moment of inertia of the body before you can use it. The easiest way to do this is calling ep_body_calculate_mass. This function will calculate the center of mass, mass and moment of inertia of the body based on the shapes you have added to the body.

// call this function after adding the shapes:
ep_body_calculate_mass(global.world,body);

Circle shapes

You can create circle shapes in the same way you create box shapes:

shape1 = ep_shape_create_circle(global.world,body,32,0,0,0,1);
// 32: the radius of the circle.
// 0,0,0: the relative coordinates of the shape (x,y,rot).
// 1: the density of the circle (not used for static bodies).

Polygon shapes

Creating polygon shapes is more complicated, because you have to create a polygon first. A polygon can be used by multiple bodies, so usually you can create all polygons immediately after creating the world.

global.poly_triangle1 = ep_polygon_create(global.world,3);
// 3: number of vertices.
ep_polygon_set_vertex(global.world,global.poly_triangle1,0,-10,-10);
// 0: first vertex.
// -10,-10: coordinates of the vertex.
ep_polygon_set_vertex(global.world,global.poly_triangle1,1,+10,+10);
// 1: second vertex.
// +10,+10: coordinates of the vertex.
ep_polygon_set_vertex(global.world,global.poly_triangle1,2,-10,+10);
// 2: third vertex.
// -10,+10: coordinates of the vertex.
ep_polygon_initialize(global.world,global.poly_triangle1);

There are two things you have to take in mind:

  • Vertices have to be declared in clockwise order (in a left-handed coordinate system).

  • All polygons have to be convex. If a body is concave you have to create multiple convex polygons. You can use multipolygons to accomplish that.

shape1 = ep_shape_create_polygon(global.world,body,global.poly_triangle1,0,0,0,1);
// global.poly_triangle1: the id of the polygon.
// 0,0,0: the relative coordinates of the shape (x,y,rot).
// 1: the density of the polygon (not used for static bodies).
Note

You can't destroy a polygon if it's still in use.

Simulating

You have to call ep_world_update_contacts and ep_world_simulate_step to simulate one step. Usually this is done in the end step event of the controller.

ep_world_update_contacts(global.world);
ep_world_simulate_step(global.world);

After simulating a step you have to update the position and orientation of the objects in Game Maker to see the results of the simulation. This is usually done in the end step event of the objects.

x = ep_body_get_x(global.world,body);
y = ep_body_get_y(global.world,body);
image_angle = radtodeg(ep_body_get_rot(global.world,body));

Destroying ExtremePhysics resources

When you destroy an object in Game Maker, you have to destroy the body too:

ep_body_destroy(global.world,body);

Don't forget to destroy the world when the player leaves the room:

// room end event
ep_world_destroy(global.world)
Hint

When a world is destroyed, all polygons, bodies, contacts, joints and views that belong to the world are destroyed. When a body is destroyed, all shapes and forces that belong to the body are destroyed.

Good luck!


Comments

N1k10s

Comment #1: Sat, 5 Jun 2010, 9:47 (GMT+1, DST)

Quote


I am simply amazed. Thank you so much for these tutorials. I shall stop by every now and then to see what might have been added. I would say that I am an intermediate when it comes to programing and that this is far beyond me. However, your tutorials make perfect sense.

One question: Are these codes free to use in other programs? It is exactly what I need for a game of mine created with GM.

Maarten Baert

Administrator

Comment #2: Wed, 23 Jun 2010, 16:37 (GMT+1, DST)

Quote


Quote: N1k10s

I am simply amazed. Thank you so much for these tutorials. I shall stop by every now and then to see what might have been added. I would say that I am an intermediate when it comes to programing and that this is far beyond me. However, your tutorials make perfect sense.

One question: Are these codes free to use in other programs? It is exactly what I need for a game of mine created with GM.

The code in this tutorial is of course completely free. The source code of the DLL is distributed under the terms of the GNU Lesser General Public License, which means you can use it in any project, but if you start making changes to the source code you have to make those changes public under the same or a similar license. If you're just using the DLL or the extension in GM, then it is "free to use, also for commercial games".

Cklester

Comment #3: Sun, 26 Sep 2010, 22:21 (GMT+1, DST)

Quote


Maarten, could you provide me with an example room of a soccer ball being dropped at an angle from a height and bouncing on a solid floor until it stops? I think that would go a long way in helping me understand how to set up the world and how to attach a sprite to a physics object.

Thank you!

Edit: I'm using GMP8

Last modified: Sun, 26 Sep 2010, 22:22 (GMT+1, DST)

Maarten Baert

Administrator

Comment #4: Tue, 28 Sep 2010, 23:56 (GMT+1, DST)

Quote


Quote: Cklester

Maarten, could you provide me with an example room of a soccer ball being dropped at an angle from a height and bouncing on a solid floor until it stops? I think that would go a long way in helping me understand how to set up the world and how to attach a sprite to a physics object.

Thank you!

Edit: I'm using GMP8

I've added a simple platform example yesterday, it should give you a good idea where to start :).

Cklester

Comment #5: Wed, 29 Sep 2010, 2:30 (GMT+1, DST)

Quote


Cool! Thanks, Maarten. I'll check it out.

Tbone

Comment #6: Thu, 7 Oct 2010, 5:32 (GMT+1, DST)

Quote


I was trying to create a simple dynamic ball to fall down onto the static blocks, but this didn't work out well. Can anyone figure out the problem please. I really would like to learn how to use this. The link is here http://www.speedyshare.com/files/24599850/Try_at_Extreme_Physics.gmk

-Thanks in Advance : )

Last modified: Fri, 8 Oct 2010, 17:35 (GMT+1, DST)

Maarten Baert

Administrator

Comment #7: Sat, 16 Oct 2010, 15:12 (GMT+1, DST)

Quote


Quote: Tbone

I was trying to create a simple dynamic ball to fall down onto the static blocks, but this didn't work out well. Can anyone figure out the problem please. I really would like to learn how to use this. The link is here http://www.speedyshare.com/files/24599850/Try_at_Extreme_Physics.gmk

-Thanks in Advance : )

  • endstep(); should be in the end step event of the controller, not in the end step event of the ball.

  • You should use ep_body_set_gravity if you want the ball to fall.

It should work now.

Tbone

Comment #8: Sat, 16 Oct 2010, 16:21 (GMT+1, DST)

Quote


Ohh...Duh! Thanks Maarten Baert. :D

I would use ep_body_set_gravity like this right?

ep_body_set_gravity(global.world,body,0,y+100);

Last modified: Sun, 17 Oct 2010, 10:12 (GMT+1, DST)

Ross93

Comment #9: Wed, 2 Mar 2011, 2:50 (GMT+1, DST)

Quote


Hey there

I've been using this physics engine and I love it!

I've written a bit of code which can easily turn this into a top-down / birds-eye view physics engine...

xx=ep_body_get_xvel_center(global.world, argument0)
yy=ep_body_get_yvel_center(global.world, argument0)
arot=ep_body_get_rotvel(global.world, argument0)
if xx !=0 then xx*=floor_friction
if yy !=0 then yy*=floor_friction
if arot != 0 then arot*=floor_friction
ep_body_set_velocity_center(global.world, argument0, xx,yy,arot)

where floor_friction is a decimal number between 0 and 1 (1 being no friction and 0 being lots of friction)

If all your bodies have 0 gravity, then if you put this in the step event you will have a working top-down physics engine. I know this is probably elementary stuff but it might help some people :)

Cheers
Ross

Maanu40

Comment #10: Wed, 2 Mar 2011, 15:51 (GMT+1, DST)

Quote


Help!

When I give the code:

ep_world_set_settings(global.world,1,20,10,0.1,0.5,0.1,0.5,1);

In the Create-event, the code editor says that there is a wrong number of arguments in this function. :S Please answer!

Maanu40

Joona

Comment #11: Fri, 4 Mar 2011, 16:00 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Tbone

I was trying to create a simple dynamic ball to fall down onto the static blocks, but this didn't work out well. Can anyone figure out the problem please. I really would like to learn how to use this. The link is here http://www.speedyshare.com/files/24599850/Try_at_Extreme_Physics.gmk

-Thanks in Advance : )

  • endstep(); should be in the end step event of the controller, not in the end step event of the ball.

  • You should use ep_body_set_gravity if you want the ball to fall.

It should work now.

Hi
I tried to combine http://www.yoyogames.com/games/54283-chain-example and your platform_example, but if I put End Step event to ball_object , I am no longer able to move it and without it, the collision does not work with obj_crate.
I wonder what I have to do with it?

Maarten Baert

Administrator

Comment #12: Sat, 5 Mar 2011, 18:39 (GMT+1, DST)

Quote


Quote: Ross93

Hey there

I've been using this physics engine and I love it!

I've written a bit of code which can easily turn this into a top-down / birds-eye view physics engine...

[...]

where floor_friction is a decimal number between 0 and 1 (1 being no friction and 0 being lots of friction)

If all your bodies have 0 gravity, then if you put this in the step event you will have a working top-down physics engine. I know this is probably elementary stuff but it might help some people :)

Cheers
Ross

You can also use ep_body_set_damping in the create event, that function does exactly the same :).

Quote: Maanu40

Help!

When I give the code:

ep_world_set_settings(global.world,1,20,10,0.1,0.5,0.1,0.5,1);

In the Create-event, the code editor says that there is a wrong number of arguments in this function. :S Please answer!

Maanu40

That code works for me. Are you sure you're using the latest version (2.2)?

Quote: Joona

Hi
I tried to combine http://www.yoyogames.com/games/54283-chain-example and your platform_example, but if I put End Step event to ball_object , I am no longer able to move it and without it, the collision does not work with obj_crate.
I wonder what I have to do with it?

That example uses GM's movement system (direction, speed, gravity, ...), which is not compatible with ExtremePhysics. You should replace them by ExtremePhysics functions, e.g. ep_body_apply_impulse to move towards the target, ep_body_set_damping to simulate friction, ...

Last modified: Sat, 5 Mar 2011, 19:00 (GMT+1, DST)

Joona

Comment #13: Sat, 5 Mar 2011, 20:45 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Joona

Hi
I tried to combine http://www.yoyogames.com/games/54283-chain-example and your platform_example, but if I put End Step event to ball_object , I am no longer able to move it and without it, the collision does not work with obj_crate.
I wonder what I have to do with it?

That example uses GM's movement system (direction, speed, gravity, ...), which is not compatible with ExtremePhysics. You should replace them by ExtremePhysics functions, e.g. ep_body_apply_impulse to move towards the target, ep_body_set_damping to simulate friction, ...

Ok, thanks, but now I have even bigger problem.
I am new with Game Maker and normal movements are still hard to me.
Can you make me an example how these functions works with mouse, if it is possible?

Maarten Baert

Administrator

Comment #14: Tue, 15 Mar 2011, 20:02 (GMT+1, DST)

Quote


Quote: Joona

Ok, thanks, but now I have even bigger problem.
I am new with Game Maker and normal movements are still hard to me.
Can you make me an example how these functions works with mouse, if it is possible?

Well, you have to understand the normal movement system first. Otherwise you won't understand the ExtremePhysics functions either. Did you read the official Game Maker tutorials?

De

Comment #15: Wed, 21 Mar 2012, 9:46 (GMT+1, DST)

Quote


hi,
i don't understand why does a circular object bounce up even when its rolling on a flat surface???
what should i do to prevent that from happening???

Maarten Baert

Administrator

Comment #16: Wed, 28 Mar 2012, 22:02 (GMT+1, DST)

Quote


Quote: De

hi,
i don't understand why does a circular object bounce up even when its rolling on a flat surface???
what should i do to prevent that from happening???

That's probably because the flat surface consists of many separate blocks in your game. You can reduce the effect by using a higher framerate (60 instead of 30) or substeps, i.e. simulating multiple steps per actual frame. The only way to actually eliminate the effect is to use a single shape for the entire surface. Take a look at the 'merging walls' example, if your game is grid-based that should be enough.

Antonslp

Comment #17: Tue, 30 Oct 2012, 7:13 (GMT+1, DST)

Quote


I am really glad I found a good tutorial, but i have got a question:
If I start the game, there is this error:

___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object object0_gamestart:

COMPILATION ERROR in code action
Error in code at line 1:
extremephysics_init();
^
at position 1: Unknown function or script: extremephysics_init

__________________________________________

The DLL is in the same directory, I've checked that multiple times, but there is always this error. What have I to do now?

Maarten Baert

Administrator

Comment #18: Tue, 30 Oct 2012, 13:48 (GMT+1, DST)

Quote


Quote: Antonslp

I am really glad I found a good tutorial, but i have got a question:
If I start the game, there is this error:

___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object object0_gamestart:

COMPILATION ERROR in code action
Error in code at line 1:
extremephysics_init();
^
at position 1: Unknown function or script: extremephysics_init

__________________________________________

The DLL is in the same directory, I've checked that multiple times, but there is always this error. What have I to do now?

You have to import the scripts (gml file) too if you want to use ExtremePhysics that way. But normally you would use the extension instead of the dll + scripts, so you don't need either of them. You don't have to call extremephysics_init if you use the extension.

Last modified: Tue, 30 Oct 2012, 13:48 (GMT+1, DST)

Gimpy

Comment #19: Wed, 2 Jan 2013, 10:32 (GMT+1, DST)

Quote


Hi Maarten. Thanks for all your great work on ExtremePhysics. I am new to the product and very excited to learn more.

I am having a beginner problem. In trying to learn the very basics of creating static and dynamic objects I am recreating one of your examples "engine_example.gmk" to try and undersand the creation flow as I follow the tutorials.

When recreate the Create Event in the static block object, I get a failure on Physics_object_set(body); I have redone it several times and have had no success.

The exact code is:
body = ep_body_create_static(global.world);
shape1 = ep_shape_create_box(global.world, body, 32, 32, 0, 0, 0, 1);
ep_shape_set_collision(global.world, body, shape1, 1, 1, 0);
ep_shape_set_material(global.world, body, shape1, 0.4, 0.4, 0, 0);

physics_object_set(body);

I would be greatful is you could explain why I am getting the error on this one function...so far.

I am using the Extension rather than the DLL.

Respectfully,

Tim Plumlee (Gimpy)

Maarten Baert

Administrator

Comment #20: Wed, 2 Jan 2013, 23:40 (GMT+1, DST)

Quote


Quote: Gimpy

Hi Maarten. Thanks for all your great work on ExtremePhysics. I am new to the product and very excited to learn more.

I am having a beginner problem. In trying to learn the very basics of creating static and dynamic objects I am recreating one of your examples "engine_example.gmk" to try and undersand the creation flow as I follow the tutorials.

When recreate the Create Event in the static block object, I get a failure on Physics_object_set(body); I have redone it several times and have had no success.

The exact code is:
body = ep_body_create_static(global.world);
shape1 = ep_shape_create_box(global.world, body, 32, 32, 0, 0, 0, 1);
ep_shape_set_collision(global.world, body, shape1, 1, 1, 0);
ep_shape_set_material(global.world, body, shape1, 0.4, 0.4, 0, 0);

physics_object_set(body);

I would be greatful is you could explain why I am getting the error on this one function...so far.

I am using the Extension rather than the DLL.

Respectfully,

Tim Plumlee (Gimpy)

It's a script, not a function :). It calls ep_body_set_position. You can also use that function directly instead of using my script, the script is just a bit easier.

Gimpy

Comment #21: Thu, 3 Jan 2013, 1:24 (GMT+1, DST)

Quote


Thank you for your fantastically quick response and the great information.

It worked perfectly.

Now I have moved on to dynamic objects and am having a failure on two other issues.

physics_object_update(body);

and

draw_sprite_corrected(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);

All these functions work in your examples. When I use exactly the same code in my test example, they fail.

Can you help me again, please. And are there any other issues like this?

I truly appreciate your help.

Respectfully,

Tim Plumlee (Gimpy)

Maarten Baert

Administrator

Comment #22: Thu, 3 Jan 2013, 2:10 (GMT+1, DST)

Quote


Quote: Gimpy

Thank you for your fantastically quick response and the great information.

It worked perfectly.

Now I have moved on to dynamic objects and am having a failure on two other issues.

physics_object_update(body);

and

draw_sprite_corrected(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);

All these functions work in your examples. When I use exactly the same code in my test example, they fail.

Can you help me again, please. And are there any other issues like this?

I truly appreciate your help.

Respectfully,

Tim Plumlee (Gimpy)

Again, they are scripts :).

Gimpy

Comment #23: Thu, 3 Jan 2013, 4:00 (GMT+1, DST)

Quote


Hi Maarten.

Thank you so much for your quick response.

Forgive me for being a complete idiot.

I knew about and completely overlooked the 3 scripts in your examples.

Everything works great now...even my brain...I hope. :o)

Thank you again so much.

Very respectfully,

Tim Plumlee (Gimpy)

Gimpy

Comment #24: Sat, 12 Jan 2013, 11:48 (GMT+1, DST)

Quote


Hi again Maarten. I have another very basic question.
am creating various polygons. I have done a hexagon and used the same code for a previous, but differently shaped polygon that works perfectly. My code shows no errors, but when the program is run in GameMaker the object speeds around the screen erratically then leaps out of view after knocking several other objects out of place.

The verticies were done by Polygon Creator and are in the Controller after the world creation as per your direction.

The create event code is apparently where my problen is. I am not sure what the variable for each function should be. Your reference information shows what each of the variables are, but I am confused over what they should be for various objects.

Here is my object creation eveent code:
body = ep_body_create_dynamic(global.world, false);
shape1 = ep_shape_create_polygon(global.world,body,global.hex_dyn,0,0,0,1);
ep_shape_set_collision(global.world, body, shape1, 1, 1, 0);
ep_shape_set_material(global.world, body, shape1, 0.4, 0.4, 0, 0);
ep_body_calculate_mass(global.world, body);
ep_body_set_gravity(global.world, body, 0, 0.2);
physics_object_set(body);

Does anything look glaringly wrong to you?

I would appreciate any help you can provide. I really enjoy working with ExtremePhysics. Even more so as I learn new bits and pieces.

Respectfully,

Tim Plumlee (Gimpy)

Maarten Baert

Administrator

Comment #25: Sun, 13 Jan 2013, 0:52 (GMT+1, DST)

Quote


Quote: Gimpy

Hi again Maarten. I have another very basic question.
am creating various polygons. I have done a hexagon and used the same code for a previous, but differently shaped polygon that works perfectly. My code shows no errors, but when the program is run in GameMaker the object speeds around the screen erratically then leaps out of view after knocking several other objects out of place.

The verticies were done by Polygon Creator and are in the Controller after the world creation as per your direction.

The create event code is apparently where my problen is. I am not sure what the variable for each function should be. Your reference information shows what each of the variables are, but I am confused over what they should be for various objects.

Here is my object creation eveent code:
body = ep_body_create_dynamic(global.world, false);
shape1 = ep_shape_create_polygon(global.world,body,global.hex_dyn,0,0,0,1);
ep_shape_set_collision(global.world, body, shape1, 1, 1, 0);
ep_shape_set_material(global.world, body, shape1, 0.4, 0.4, 0, 0);
ep_body_calculate_mass(global.world, body);
ep_body_set_gravity(global.world, body, 0, 0.2);
physics_object_set(body);

Does anything look glaringly wrong to you?

I would appreciate any help you can provide. I really enjoy working with ExtremePhysics. Even more so as I learn new bits and pieces.

Respectfully,

Tim Plumlee (Gimpy)

Your code looks okay, so I suspect there's something wrong with the code that creates the polygon. Could you post that one too?

By the way, have you tried debug drawing? That usually helps a lot.

Last modified: Sun, 13 Jan 2013, 0:53 (GMT+1, DST)

Gimpy

Comment #26: Sun, 13 Jan 2013, 9:49 (GMT+1, DST)

Quote


Hi Maarten,

Per your request here is the code placed into the controller which describes the hexgon I am having a problem with...

//hex_dyn
global.hex_dyn = ep_polygon_create(global.world,6);
ep_polygon_set_vertex(global.world,global.hex_dyn,0,-96,-164);
ep_polygon_set_vertex(global.world,global.hex_dyn,1,97,-164);
ep_polygon_set_vertex(global.world,global.hex_dyn,2,193,0);
ep_polygon_set_vertex(global.world,global.hex_dyn,3,97,166);
ep_polygon_set_vertex(global.world,global.hex_dyn,4,-99,162);
ep_polygon_set_vertex(global.world,global.hex_dyn,5,-193,0);
ep_polygon_initialize(global.world,global.hex_dyn)

I hope this gives you some assistance in figuring out what I am doing incorrectly.

Respectfully as always,

Tim Plumlee (Gimpy)

Maarten Baert

Administrator

Comment #27: Sun, 13 Jan 2013, 20:17 (GMT+1, DST)

Quote


That looks correct. Does debug drawing show anything useful?

Gimpy

Comment #28: Sun, 13 Jan 2013, 22:14 (GMT+1, DST)

Quote


Hi Maarten,

I complete removed all traces of my previous code and built it from scratch again.

It works perfectly. ??

Thank you for your rapid responses and assistance in getting me past another 'junior road bump'.

Most respectfully,

Tim Plumlee (Gimpy)

Gimpy

Comment #29: Tue, 12 Feb 2013, 9:59 (GMT+1, DST)

Quote


Hi again, Maarten.

I am working on a simple 'shooter game.

I have 10 different dynamic objects with 10 different sprites.

When I knock all 10 0objects off the screen I want to go to the next level.

I use the Gamemaker language or drag and drop to check for any remaining objects on the screen. When they are all gone, the game will not change levels.

I there anything 'unseen' that is left behind when a dynamic objects sprite falls off screen?

I understood the dynamic object and its sprite were connected and moved as one. ??

Or am I just having a problem with my gamemaker code?

This may not be the proper section to post a question of this nature. If not, I apologize.

Thanks for any information you can offer.

Respectfully,

Tim Plumlee (Gimpy)

Maarten Baert

Administrator

Comment #30: Thu, 14 Feb 2013, 3:02 (GMT+1, DST)

Quote


Quote: Gimpy

Hi again, Maarten.

I am working on a simple 'shooter game.

I have 10 different dynamic objects with 10 different sprites.

When I knock all 10 0objects off the screen I want to go to the next level.

I use the Gamemaker language or drag and drop to check for any remaining objects on the screen. When they are all gone, the game will not change levels.

I there anything 'unseen' that is left behind when a dynamic objects sprite falls off screen?

I understood the dynamic object and its sprite were connected and moved as one. ??

Or am I just having a problem with my gamemaker code?

This may not be the proper section to post a question of this nature. If not, I apologize.

Thanks for any information you can offer.

Respectfully,

Tim Plumlee (Gimpy)

This should work, it doesn't matter whether you move the instances manually or let ExtremePhysics do it. I think the problem is in your code. How are you checking whether there are instances on screen?

Gimpy

Comment #31: Fri, 15 Feb 2013, 8:10 (GMT+1, DST)

Quote


Hi Maarten,

Thanks for your response.

The problem was indeed my own code.

ExtremePhysics is working perfectly for me.

Thank you again.

Always respectfully,

Tim Plumlee (Gimpy)

Dynamictoys

Comment #32: Thu, 14 Mar 2013, 23:34 (GMT+1, DST)

Quote


Hi,

Does this one work on GM Master? I try the demo program but it does not work.
It show up "Error: GM functions could not be initialized!".

Seem like the ep_gm_functions_init() return error.

I also try this
ep_gm_functions_init_address(get_function_address("get_function_address"))

but compiler could not find function get_function_address

Thanks!

Maarten Baert

Administrator

Comment #33: Fri, 15 Mar 2013, 0:56 (GMT+1, DST)

Quote


Quote: Dynamictoys

Hi,

Does this one work on GM Master? I try the demo program but it does not work.
It show up "Error: GM functions could not be initialized!".

I'm not sure what you mean by 'GM Master' - GM Studio?

Debug drawing doesn't work in GM Studio and will probably never work because it's essentially a hack. There's not much I can do about this, especially since get_function_address is gone.

Gimpy

Comment #34: Fri, 15 Mar 2013, 12:10 (GMT+1, DST)

Quote


Hi Maarten,

I have a program that requires a platform moving back and forth horizontally.

I need the platform to be a static physics object. All it does is move left and right.

I do not want a dynamic 'bullet' to pass through the platform.

The routine for moving the platform works perfectly. The sprite object the physics object is attached to moves, but the physics object remains stationary.

I can shoot where the object was originally placed while the visible sprite is moving and the 'invisible' physics object is still in the original location.

Sorry for the long post, I was trying to be as clear as possible.

How can I cause the physics object to along move with the platform so a dynamic bullet will bounce off and not pass through it?

Thank for all your help.

Respectfully,

Gimpy

Maarten Baert

Administrator

Comment #35: Sun, 17 Mar 2013, 0:46 (GMT+1, DST)

Quote


Quote: Gimpy

Hi Maarten,

I have a program that requires a platform moving back and forth horizontally.

I need the platform to be a static physics object. All it does is move left and right.

I do not want a dynamic 'bullet' to pass through the platform.

The routine for moving the platform works perfectly. The sprite object the physics object is attached to moves, but the physics object remains stationary.

I can shoot where the object was originally placed while the visible sprite is moving and the 'invisible' physics object is still in the original location.

Sorry for the long post, I was trying to be as clear as possible.

How can I cause the physics object to along move with the platform so a dynamic bullet will bounce off and not pass through it?

Thank for all your help.

Respectfully,

Gimpy

Don't change x and y of your instance, it won't work like that. Don't change the position of the body either because that will make the platform 'teleport' to the new location each step while everything resting on the platform will stay stationary. You should change the velocity of the body and let ExtremePhysics move it (ep_body_set_velocity_center). You should also add this to the end step event:

x = ep_body_get_x(global.world,body);
y = ep_body_get_y(global.world,body);
image_angle = radtodeg(ep_body_get_rot(global.world,body));

Last modified: Sun, 17 Mar 2013, 0:46 (GMT+1, DST)

Gimpy

Comment #36: Mon, 18 Mar 2013, 18:16 (GMT+1, DST)

Quote


Hi Maarten,

Thanks for your excellent help.

My moving platforms work perfectly.

Respectfully,

Gimpy

Icy Hell

Comment #37: Tue, 22 Oct 2013, 17:02 (GMT+1, DST)

Quote


Hi Maarten,
Extreme Physics is a really great extension for GameMaker.
But it can not run properly on GMS(even on Windows), all instances are stack at the top of room, include static objects.
All code are copied from Getting Started tutorial.

Sorry about my poor English~ :)

Maarten Baert

Administrator

Comment #38: Wed, 23 Oct 2013, 23:47 (GMT+1, DST)

Quote


Quote: Icy Hell

Hi Maarten,
Extreme Physics is a really great extension for GameMaker.
But it can not run properly on GMS(even on Windows), all instances are stack at the top of room, include static objects.
All code are copied from Getting Started tutorial.

Sorry about my poor English~ :)

Make sure you are using the extension for Studio. I have heard that it works for some other people, but I don't have Studio so I can't really help you there.

PS: Debug drawing doesn't work in Studio, I can't fix that because YYG removed the function I needed.

Icy Hell

Comment #39: Sat, 26 Oct 2013, 12:34 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Icy Hell

Hi Maarten,
Extreme Physics is a really great extension for GameMaker.
But it can not run properly on GMS(even on Windows), all instances are stack at the top of room, include static objects.
All code are copied from Getting Started tutorial.

Sorry about my poor English~ :)

Make sure you are using the extension for Studio. I have heard that it works for some other people, but I don't have Studio so I can't really help you there.

PS: Debug drawing doesn't work in Studio, I can't fix that because YYG removed the function I needed.

Yes, I'm using the extension. And I started my project over again, this time is different: everything falls correctly but they don't collide with each other.

I'm using GameMaker:Studio 1.2.1130. I can give you a cracked GMS if you want. (Sorry to Yoyogames)

Maarten Baert

Administrator

Comment #40: Sat, 26 Oct 2013, 18:15 (GMT+1, DST)

Quote


Quote: Icy Hell

Yes, I'm using the extension. And I started my project over again, this time is different: everything falls correctly but they don't collide with each other.

Sure, but are you using the extension for Studio? There are two extensions, and only one will work in Studio :).

Make sure you have the latest version of ExtremePhysics as well.

Icy Hell

Comment #41: Sat, 26 Oct 2013, 18:33 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Icy Hell

Yes, I'm using the extension. And I started my project over again, this time is different: everything falls correctly but they don't collide with each other.

Sure, but are you using the extension for Studio? There are two extensions, and only one will work in Studio :).

Make sure you have the latest version of ExtremePhysics as well.

Yes, Extreme Physics 2.2 for Studio. Probably my GMS version is too high.
link removed

Last modified: Sun, 27 Oct 2013, 19:17 (GMT+1, DST)

Maarten Baert

Administrator

Comment #42: Sun, 27 Oct 2013, 19:21 (GMT+1, DST)

Quote


Quote: Icy Hell

Yes, Extreme Physics 2.2 for Studio. Probably my GMS version is too high.
link removed

Please don't post these links here.

Have you tried any of the examples? Do they work?

Are you sure that this is related to Studio and not just a bug in your code? If it was a Studio problem, it shouldn't change when you start the project over ...

If you can create a GM7/GM8/GM8.1 version that has the same bug, I can take a look at it.

Icy Hell

Comment #43: Tue, 29 Oct 2013, 5:36 (GMT+1, DST)

Quote


Quote: Maarten Baert

Please don't post these links here.

Have you tried any of the examples? Do they work?

Are you sure that this is related to Studio and not just a bug in your code? If it was a Studio problem, it shouldn't change when you start the project over ...

If you can create a GM7/GM8/GM8.1 version that has the same bug, I can take a look at it.

Sorry about that link. I tried engine_exmaple.gmk in GMS. All dynamic objects stack at top-left corner of the room.

And sorry about the error that object don't collide with each other, that error was happened when I using GMS built-in Physics engine...

Maarten Baert

Administrator

Comment #44: Sat, 2 Nov 2013, 2:26 (GMT+1, DST)

Quote


Quote: Icy Hell

Sorry about that link. I tried engine_exmaple.gmk in GMS. All dynamic objects stack at top-left corner of the room.

And sorry about the error that object don't collide with each other, that error was happened when I using GMS built-in Physics engine...

That bug usually happens when you try to use the non-Studio extension in Studio. Are you sure that you have the Studio version? What steps did you follow to install it? IIRC you need to run GM as administrator to install extensions (this may have changed in Studio though).

What version of ExtremePhysics do you see in the extensions dialog? It should be 2.2 release 15 (the release number is important).

Kristian221

Comment #45: Wed, 6 Nov 2013, 23:52 (GMT+1, DST)

Quote


To start off with I am just trying to get a ball to fall down, but I seem to be having trouble with it.

The Controller:
Create Event:
global.world=ep_world_create()
ep_world_set_settings(global.world,1,20,10,0.1,0.5,0,0.5,1)

End Step Event:
ep_world_update_contacts(global.world);
ep_world_simulate_step(global.world);

The Ball:
Create Event:
body = ep_body_create_dynamic(global.world, 0)
shape = ep_shape_create_circle(global.world,body,16,0,0,0,1)
ep_shape_set_material(global.world,body,shape,0.5,0.4,0,0)
ep_body_set_position(global.world,body,x,y,degtorad(image_angle));
ep_body_calculate_mass(global.world,body)

End Step Event:
x = ep_body_get_x(global.world,body);
y = ep_body_get_y(global.world,body);
image_angle = radtodeg(ep_body_get_rot(global.world,body));

The ball just floats there. I am using the extension package that is NOT labeled studio.

Also, for some strange reason whenever I open up one of your examples in GM8.1 they appear to be blank.

Maarten Baert

Administrator

Comment #46: Thu, 7 Nov 2013, 19:43 (GMT+1, DST)

Quote


@Kristian221: You forgot ep_body_set_gravity :).

Lukayson

Comment #47: Tue, 19 Aug 2014, 19:54 (GMT+1, DST)

Quote


Hi, I am here to ask you, and very thank you, all my gm project are based on your awesome physics. My issue is that I bought YOYO Compiler (YYC) for GM Studio, EP 2.2 seems to not working with YYC. Is there chance that it will run?
Please answer
Thank you.

PS
I have solution how to run graphic debug vison of physics bodies in GM Studio, if you are interested, a can send you example

Maarten Baert

Administrator

Comment #48: Thu, 21 Aug 2014, 19:48 (GMT+1, DST)

Quote


Quote: Lukayson

Hi, I am here to ask you, and very thank you, all my gm project are based on your awesome physics. My issue is that I bought YOYO Compiler (YYC) for GM Studio, EP 2.2 seems to not working with YYC. Is there chance that it will run?

I don't have Studio, I have no idea. Do other DLLs work with YYC?

Quote: Lukayson

I have solution how to run graphic debug vison of physics bodies in GM Studio, if you are interested, a can send you example

I wouldn't be able to open the example since I don't have Studio, but I'd like to know how you made that work.

Lukayson

Comment #49: Fri, 22 Aug 2014, 11:25 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Lukayson

Hi, I am here to ask you, and very thank you, all my gm project are based on your awesome physics. My issue is that I bought YOYO Compiler (YYC) for GM Studio, EP 2.2 seems to not working with YYC. Is there chance that it will run?

I don't have Studio, I have no idea. Do other DLLs work with YYC?

I have only EP, but its good ide to try some alse.

Quote: Maarten Baert
Quote: Lukayson

I have solution how to run graphic debug vison of physics bodies in GM Studio, if you are interested, a can send you example

I wouldn't be able to open the example since I don't have Studio, but I'd like to know how you made that work.

I made it comletly inside game maker using GML. I can sen you gmk example
it is not that comfortable, like native solution ep_debugdraw_bodies, but I was not able to work until I can see bodies again
if you are stil interested, tell me haw I can send it

Last modified: Fri, 22 Aug 2014, 14:57 (GMT+1, DST)

Maarten Baert

Administrator

Comment #50: Fri, 22 Aug 2014, 14:59 (GMT+1, DST)

Quote


Quote: Lukayson

I made it comletly inside game maker using GML. I can sen you gmk example
it is not that comfortable, like native solution ep_debugdraw_bodies, but I was not able to work until I can see bodies again
if you are stil interested, tell me haw I can send it

I see. That may still be useful for other users. Can you post the code here? If it's too large, you can use pastebin.com.

Lukayson

Comment #51: Sun, 24 Aug 2014, 0:23 (GMT+1, DST)

Quote


There is download link of my Example solution that allows debug draw bodies in Game Maker Studio.
GM Studio does not support ep_debugdraw_bodies natively, so I helped myself, and maybe it will help you also.

My solution is not that comfortable to use, compared to native function ep_debugdraw_bodies, but at least its something that work

I made this example, because I have this problem in my game which is in development now. Dev name is Space Plan

I have also example of advanced 2d animation/clothing system, with animation creator that i made in GM ,
everything easy to use, I can post it if there is someone interested.

email: lukayson@gmail.com

Download Link: Extreme Physics Debug Draw in GM Studio.zip :
https://dl.dropboxusercontent.com/u/68808500/Extreme%20Physics%20Debug%20Draw%20in%20GM%20Studio.zip

Lukayson

Comment #52: Wed, 3 Dec 2014, 2:11 (GMT+1, DST)

Quote


I would just like to mention that Extreme physics is now fully working with YoYo Compiler (YYC), after latest GM Studio update. I'm very happy about that

Lukayson

Comment #53: Mon, 31 Oct 2016, 22:56 (GMT+1, DST)

Quote


Hello, I want to release game on steam that uses EP, what is necesary to do? I am not good at understanding law things. like terms, logos, credits and more. Thank you . There is trailer I am preparing: https://youtu.be/miS2w9x9ccY

Maarten Baert

Administrator

Comment #54: Tue, 1 Nov 2016, 1:47 (GMT+1, DST)

Quote


Quote: Lukayson

Hello, I want to release game on steam that uses EP, what is necesary to do? I am not good at understanding law things. like terms, logos, credits and more. Thank you . There is trailer I am preparing: https://youtu.be/miS2w9x9ccY

You should have some kind of 'about' page or similar where you have all the copyright information for your game. There you should say something like this:

Quote

This game uses the third-party ExtremePhysics library created by Maarten Baert for physics simulation. ExtremePhysics is distributed under the terms of the GNU Lesser General Public License. The source code can be found at:
http://www.maartenbaert.be/extremephysics/

For most practical purposes that's enough. If you really want to follow the rules to the letter, then you have to also host the ExtremePhysics source code on your own website or include it with the Steam game itself, but in practice most people just link to the original project website since it's much more convenient.

One small thing about the LGPL is that you have to allow users to replace the ExtremePhysics DLL, if they want to. So you can't e.g. calculate MD5 checksums of the library to check that it hasn't been changed, that would break the LGPL. The idea is that people can replace outdated versions with more up-to-date versions to fix bugs etc. I doubt that anyone will actually do that, but that's just how the license works.

Last modified: Tue, 1 Nov 2016, 1:48 (GMT+1, DST)

Lukayson

Comment #55: Tue, 1 Nov 2016, 12:28 (GMT+1, DST)

Quote


Quote: Maarten Baert
Quote: Lukayson

Hello, I want to release game on steam that uses EP, what is necesary to do? I am not good at understanding law things. like terms, logos, credits and more. Thank you . There is trailer I am preparing: https://youtu.be/miS2w9x9ccY

You should have some kind of 'about' page or similar where you have all the copyright information for your game. There you should say something like this:

Quote

This game uses the third-party ExtremePhysics library created by Maarten Baert for physics simulation. ExtremePhysics is distributed under the terms of the GNU Lesser General Public License. The source code can be found at:
http://www.maartenbaert.be/extremephysics/

For most practical purposes that's enough. If you really want to follow the rules to the letter, then you have to also host the ExtremePhysics source code on your own website or include it with the Steam game itself, but in practice most people just link to the original project website since it's much more convenient.

One small thing about the LGPL is that you have to allow users to replace the ExtremePhysics DLL, if they want to. So you can't e.g. calculate MD5 checksums of the library to check that it hasn't been changed, that would break the LGPL. The idea is that people can replace outdated versions with more up-to-date versions to fix bugs etc. I doubt that anyone will actually do that, but that's just how the license works.

Thank you very much,
so I include EP in licence folder, in state I downloaded it from your page?
if I never heard of MD5, its automaticly OK?
Do I have to mention something in credits when game ends, or show some EP logo when game starts? Thank you

Write a comment