Jump to content


Photo

Extremephysics - 2d Physics Engine For Game Maker


  • Please log in to reply
1138 replies to this topic

#1001 ean

ean

    GMC Member

  • New Member
  • 190 posts
  • Version:GM8

Posted 30 December 2011 - 02:06 AM

Well, I needed to adjust the actual rotation because I wanted the body to move based on the previous turn angle and speed. I didn't want to apply torque...

Anyway, I've decided to stick with joints so lets forget all of that. I'll double check that the joints are destroyed, is there anything else I should look for?
  • 0

#1002 KnnO

KnnO

    GMC Member

  • GMC Member
  • 59 posts
  • Version:Unknown

Posted 30 December 2011 - 02:23 PM

I forgot to post the link again -.-
http://andere.maarte...oject_Truck.zip

Oh thank you I appreciate it !!! :D
  • 0

#1003 Questionare

Questionare

    (BEN)

  • New Member
  • 160 posts
  • Version:GM8

Posted 30 December 2011 - 11:23 PM

I want to use sprites for all the different pieces of a ragdoll...is there an easy way to do this? All of the examples that came with the program were either one piece or were drawn using the ep_debugdraw_body function.
Do I just use the draw_sprite_ext and find all the variables with stuff like ep_body_get_x? I tried this with very little success...
I'm very new to the engine, and any help is appreciated, so thanks.

PS I tried doing the ep_debugdraw_bodies thing to see how close my draw_sprite_ext was to the real thing, and it gave me an error saying that gm functions have not been initialized...idk what that means but it sounds like it could be a problem.

Edited by Questionare, 30 December 2011 - 11:27 PM.

  • 0

#1004 ean

ean

    GMC Member

  • New Member
  • 190 posts
  • Version:GM8

Posted 30 December 2011 - 11:25 PM

Well you were right about the joints, I wasn't destroying all of them so it solved the lag, but it still doesn't work. After I turn right it can't turn back left, even if I stop moving and hold the left key for several seconds.

There's one thing I haven't told you though, I've scaled the car down to about 1% of it's size in the car example.

EDit: i think I know what I'm doing wrong, I modified this: steer += max(-4, min(4, co-steer)); and put steer = wheel_angle instead, which caused problems. How would I input the wheel value instead, because anything except controls_steer=key_left-key_right doesn't work. I even tried normalizing the wheel value, which didn't work. Even rounding and normalizing it didn't work.

Also, the physics seem really basic, not smooth like the car physics 3 example. For example, the car slows down too much on a slow turn.

I set the xx+lengthdir_x(.01, direction+steer_left), yy+lengthdir_y(.01, direction+steer_left)); to .01 instead of "1" which made the physics more fun, but now the turn gets locked like before, even when I use the original turn-code.

Edited by ean, 31 December 2011 - 12:01 AM.

  • 0

#1005 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 03 January 2012 - 01:31 AM

Hi!

What the heck is this? I can't create custom polygons!

Image Link

What is the best way for making custom / random polygons?

I store each points x and y in an array, and make a variable that indicate how many points there is.

points = 10
point[0,0] = x
point[0,1] = y

Now. How can you make so these polygons are randomly generated and automaticly make a working polygon without these ****ty convex errors??

Please help! Thx

Edited by Universal_X, 03 January 2012 - 02:38 AM.

  • 0

#1006 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 03 January 2012 - 02:02 AM

I want to use sprites for all the different pieces of a ragdoll...is there an easy way to do this? All of the examples that came with the program were either one piece or were drawn using the ep_debugdraw_body function.
Do I just use the draw_sprite_ext and find all the variables with stuff like ep_body_get_x? I tried this with very little success...
I'm very new to the engine, and any help is appreciated, so thanks.

PS I tried doing the ep_debugdraw_bodies thing to see how close my draw_sprite_ext was to the real thing, and it gave me an error saying that gm functions have not been initialized...idk what that means but it sounds like it could be a problem.


It's very easy!

Just draw each sprite for each part using the ep_body_get_x. and ep_body_get_rot functions
remember that the ep_body_get_rot function return the value in rad.

So you need to convert it to degrees.
body_part_angle = radtodeg(ep_body_get_rot(bodypart))

Edited by Universal_X, 03 January 2012 - 03:02 AM.

  • 0

#1007 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 03 January 2012 - 01:39 PM

PS I tried doing the ep_debugdraw_bodies thing to see how close my draw_sprite_ext was to the real thing, and it gave me an error saying that gm functions have not been initialized...idk what that means but it sounds like it could be a problem.

You should use ep_gm_functions_init, or ep_gm_functions_init_address for GM8.1:
http://www.maartenbaert.be/extremephysics/reference/debug-drawing/

Well you were right about the joints, I wasn't destroying all of them so it solved the lag, but it still doesn't work. After I turn right it can't turn back left, even if I stop moving and hold the left key for several seconds.

There's one thing I haven't told you though, I've scaled the car down to about 1% of it's size in the car example.

EDit: i think I know what I'm doing wrong, I modified this: steer += max(-4, min(4, co-steer)); and put steer = wheel_angle instead, which caused problems. How would I input the wheel value instead, because anything except controls_steer=key_left-key_right doesn't work. I even tried normalizing the wheel value, which didn't work. Even rounding and normalizing it didn't work.

Also, the physics seem really basic, not smooth like the car physics 3 example. For example, the car slows down too much on a slow turn.

I set the xx+lengthdir_x(.01, direction+steer_left), yy+lengthdir_y(.01, direction+steer_left)); to .01 instead of "1" which made the physics more fun, but now the turn gets locked like before, even when I use the original turn-code.

Can you upload the GMK?

Hi!

What the heck is this? I can't create custom polygons!

Image Link

What is the best way for making custom / random polygons?

I store each points x and y in an array, and make a variable that indicate how many points there is.

points = 10
point[0,0] = x
point[0,1] = y

Now. How can you make so these polygons are randomly generated and automaticly make a working polygon without these ****ty convex errors??

Please help! Thx

Are the points in clockwise order? And are you sure you're setting them correctly? You should also make sure that the polygon doesn't self-intersect.

An easy way to create random shapes is to disable the errors (set the second argument of ep_world_multipoly_end to false), and repeat until you get a valid polygon (ep_world_multipoly_end returns whether the polygon was valid). This method might be very slow though, especially for complex random polygons.

Edited by Maarten Baert, 03 January 2012 - 01:40 PM.

  • 0

#1008 ean

ean

    GMC Member

  • New Member
  • 190 posts
  • Version:GM8

Posted 03 January 2012 - 05:46 PM

Well, I had to remove a bunch of the resources because my server doesn't have much space left, so it won't run. But you have the code of the 2 physics objects, the track (its like the main physics object) and the car, and several scripts.

http://www.host-a.ne...ten Baert2.gm81

The error is simply this...when the car turns right you cannot turn it left again.

Edited by ean, 03 January 2012 - 05:46 PM.

  • 0

#1009 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 03 January 2012 - 07:38 PM

Are the points in clockwise order? And are you sure you're setting them correctly? You should also make sure that the polygon doesn't self-intersect.

An easy way to create random shapes is to disable the errors (set the second argument of ep_world_multipoly_end to false), and repeat until you get a valid polygon (ep_world_multipoly_end returns whether the polygon was valid). This method might be very slow though, especially for complex random polygons.


Ok thanks. I will try that

But does the first vertex need to be id 0?

Edited by Universal_X, 16 January 2012 - 06:00 PM.

  • 0

#1010 ean

ean

    GMC Member

  • New Member
  • 190 posts
  • Version:GM8

Posted 12 January 2012 - 06:46 PM

Oh I solved the problem. Had nothing to do with your engine, it was quite simple really. Wheel was not resetting to zero because if abs(wheel)>30*sign(wheel) should have been abs(wheel)>30.

Very simple solution.
  • 0

#1011 NeutralD

NeutralD

    GMC Member

  • GMC Member
  • 22 posts
  • Version:Unknown

Posted 14 January 2012 - 10:52 PM

Maarten Baert , could you, please, add an example of colliding rope in ExtremePhysics?

It would be very usefull not for me only. I saw your draw_rope script, it's beatiful, but there is no collisions. I'm working on a project in which rope physics is an essential part.

Thank you.
  • 0

#1012 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 18 January 2012 - 01:57 PM

Maarten Baert , could you, please, add an example of colliding rope in ExtremePhysics?

It would be very usefull not for me only. I saw your draw_rope script, it's beatiful, but there is no collisions. I'm working on a project in which rope physics is an essential part.

Thank you.

Create a chain of small balls connected by distance joints with an upper limit. I've made an example:
http://andere.maartenbaert.be/ep_rope.gmk
  • 0

#1013 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 19 January 2012 - 07:52 PM

How can you get the xy start and end position for distant joints?

I see no current function that will return those values. Can you please make one? I would really apprentice that :D

Thx in advance.
  • 0

#1014 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 19 January 2012 - 10:29 PM

How can you get the xy start and end position for distant joints?

I see no current function that will return those values. Can you please make one? I would really apprentice that :D

Thx in advance.

ep_body_coord_world_to_local_x/_y. You already know the local coordinates because you set them yourself :).
  • 0

#1015 NeutralD

NeutralD

    GMC Member

  • GMC Member
  • 22 posts
  • Version:Unknown

Posted 23 January 2012 - 08:27 AM

Thank you again for the rope example and your awesome engine!

But now I've got certain problems. I'm using a part of your draw_rope script, but I don't need that much calculations. Rope primitive's texture is not repeated correctly now. Here is my draw_rope code:

var d, w, h, xx, yy;

w = background_get_width(bg_rope);
h = background_get_height(bg_rope);

var x1, x2, y1, y2, len;

    draw_set_color(c_white);
    texture_set_repeat(true);

    draw_primitive_begin_texture(pr_trianglestrip, background_get_texture(bg_rope));
for (i = 1; i <= iMax; i += 1)
   {
    x1 = ep_body_get_x(global.world, line_body[i-1]);
    y1 = ep_body_get_y(global.world, line_body[i-1]);
    x2 = ep_body_get_x(global.world, line_body[i]);
    y2 = ep_body_get_y(global.world, line_body[i]);
    xx = x2-x1;
    yy = y2-y1;
    d = sqrt(xx*xx+yy*yy);
    if d > 0.01 {
    xx *= h/2/d;
    yy *= h/2/d;
    len = (iMax/2); //here we have some trouble
    draw_vertex_texture(x1-yy-0.5, y1+xx-0.5, 0, 1);
    draw_vertex_texture(x1+yy-0.5, y1-xx-0.5, 0, 0);
    draw_vertex_texture(x2-yy-0.5, y2+xx-0.5, len/w, 1);
    draw_vertex_texture(x2+yy-0.5, y2-xx-0.5, len/w, 0);
                }
    }   
    draw_primitive_end();

I've tried to calculate length by summing distance between point[i-1] and point[i]. But that doesn't work. Could you tell what I'm doing wrong?
  • 0

#1016 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 23 January 2012 - 07:07 PM

You have to increase the texture coordinate after each piece. And you only have to draw two vertices per piece, not four (except for the first segment). Try this:
var d, w, h, xx, yy, x1, x2, y1, y2, tt;

w = background_get_width(bg_rope);
h = background_get_height(bg_rope);
tt = 0;

draw_set_color(c_white);
texture_set_repeat(true);

draw_primitive_begin_texture(pr_trianglestrip, background_get_texture(bg_rope));
for (i = 1; i <= iMax; i += 1) {
    x1 = ep_body_get_x(global.world, line_body[i-1]);
    y1 = ep_body_get_y(global.world, line_body[i-1]);
    x2 = ep_body_get_x(global.world, line_body[i]);
    y2 = ep_body_get_y(global.world, line_body[i]);
    xx = x2-x1;
    yy = y2-y1;
    d = sqrt(xx*xx+yy*yy);
    if d > 0.01 {
        xx *= h/2/d;
        yy *= h/2/d;
    } else {
        xx = h/2;
        yy = 0;
    }
    tt += d/w;
    if i = 1 {
        draw_vertex_texture(x1-yy-0.5, y1+xx-0.5, 0, 1);
        draw_vertex_texture(x1+yy-0.5, y1-xx-0.5, 0, 0);
    }
    draw_vertex_texture(x2-yy-0.5, y2+xx-0.5, tt, 1);
    draw_vertex_texture(x2+yy-0.5, y2-xx-0.5, tt, 0);
}   
draw_primitive_end();

  • 0

#1017 Scyler_27

Scyler_27

    -Insane Kid-

  • GMC Member
  • 2745 posts
  • Version:GM:Studio

Posted 28 January 2012 - 02:29 AM

Hey, this is my first time using this extension and I am coming across a problem I can't seem to figure out.

I decided to try out this engine for a pinball game, and everything is working great thus far with one setback. After bouncing the ball around for a little bit, it seemingly bounces, then just freezes in mid-air completely stuck. The velocities usually are still ranging from (-0.03,-0.03) to (0.03,0.03) but the ball just stays there. I could just be using the extension wrong (highly likely), or perhaps it is something a little glitchy?

I DO have a large amount of static bodies (lines) to define the arena (around 2000), two paddles, and a ball thus far. Here is (most of) the code for the ball:

CREATE EVENT:
mybody=ep_body_create_dynamic(PHX_world,false);
myshape=ep_shape_create_circle(PHX_world,mybody,8,0,0,0,1);
ep_shape_set_collision(PHX_world,mybody,myshape,1,1|2,1);
ep_shape_set_material(PHX_world,mybody,myshape,0.4,0.4,0,0);

ep_body_calculate_mass(PHX_world,mybody);
ep_body_set_gravity(PHX_world,mybody,0,0.002);

ep_body_set_position(PHX_world,mybody,x,y,0);

my_angle=0;

END STEP:
x=ep_body_get_x(PHX_world,mybody);
y=ep_body_get_y(PHX_world,mybody);

my_angle=radtodeg(ep_body_get_rot(PHX_world,mybody));

KEYBOARD PRESS ENTER:
 ep_body_set_position(PHX_world,mybody,xstart,ystart,0);
 ep_body_set_velocity_local_point(PHX_world,mybody,0,-2,0,0,0);

Physics world is created and updated pretty much the same as the platformer example.

The boundaries are a bunch of line shapes attached to one body, generated from a .ini file.

Am I doing something wrong here? I will admit some of these arguments I am not sure I understand and keep the default values placed from the platform example, perhaps I messed something up there.

Anyway, any help on the issue is appreciated. With the exception of this problem, this engine is fantastic. :D

EDIT: P.S., Sometimes the ball freezes after a few seconds, sometimes after a few minutes. It is rather random.

EDIT 2: P.P.S., Hm... did it almost every time I tested it, now I can't seem to get it to do it at all. I really don't know what is up here. -.-"

Edited by Scyler_27, 28 January 2012 - 03:12 AM.

  • 0

#1018 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 28 January 2012 - 04:30 PM

Are you using the sleeping system? If you do, make sure the maximum velocity for sleeping is low enough and the required time is high enough. Or simply disable sleeping completely, I don't think it's useful for a pinball game since the only thing that moves is the ball :).

The code that enables the sleeping system is probably in the create event of the controller if your game is based on one of the examples.

Edited by Maarten Baert, 28 January 2012 - 04:33 PM.

  • 0

#1019 Scyler_27

Scyler_27

    -Insane Kid-

  • GMC Member
  • 2745 posts
  • Version:GM:Studio

Posted 29 January 2012 - 01:02 AM

Ahh, yes I was. Thank you! I disabled it, and have yet to come across a problem in that regard. Thanks for the help. :)
  • 0

#1020 Tyrannosaurus rex

Tyrannosaurus rex

    GMC Member

  • GMC Member
  • 493 posts

Posted 03 February 2012 - 06:23 AM

This engine is really awesome when it comes to handling simple graphics, but something that has large sprites and multiple animations seems like a real nightmare when we go on to declare the variables;

body = ep_body_create_dynamic(global.world,true);

shape1 = ep_shape_create_ [b]!!!!!!!  [/b][size="3"][/size] 

ep_world_collision_test_box(global.world,   ww, hh-1, x+ww/2-1, y+hh/2-0.5, 0, -0.1, 0,   2, group));


Maarten, isn't there any way to snap the shape create function or the collision box on a few points that are connected around the outline of the sprites? I realise there is a polygon maker there, but when trying to make a character of this shape, size and animations:


My link


It seems impossible.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users