Extremephysics - 2d Physics Engine For Game Maker
#1001
Posted 30 December 2011 - 02:06 AM
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?
#1002
Posted 30 December 2011 - 02:23 PM
Oh thank you I appreciate it !!!I forgot to post the link again -.-
http://andere.maarte...oject_Truck.zip
#1003
Posted 30 December 2011 - 11:23 PM
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.
#1004
Posted 30 December 2011 - 11:25 PM
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.
#1005
Posted 03 January 2012 - 01:31 AM
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.
#1006
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.
#1007
Posted 03 January 2012 - 01:39 PM
You should use ep_gm_functions_init, or ep_gm_functions_init_address for GM8.1: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.
http://www.maartenbaert.be/extremephysics/reference/debug-drawing/
Can you upload the GMK?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.
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.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
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.
#1008
Posted 03 January 2012 - 05:46 PM
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.
#1009
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.
#1010
Posted 12 January 2012 - 06:46 PM
Very simple solution.
#1011
Posted 14 January 2012 - 10:52 PM
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.
#1012
Posted 18 January 2012 - 01:57 PM
Create a chain of small balls connected by distance joints with an upper limit. I've made an example: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.
http://andere.maartenbaert.be/ep_rope.gmk
#1013
Posted 19 January 2012 - 07:52 PM
I see no current function that will return those values. Can you please make one? I would really apprentice that :D
Thx in advance.
#1014
Posted 19 January 2012 - 10:29 PM
ep_body_coord_world_to_local_x/_y. You already know the local coordinates because you set them yourselfHow 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
Thx in advance.
#1015
Posted 23 January 2012 - 08:27 AM
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?
#1016
Posted 23 January 2012 - 07:07 PM
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();
#1017
Posted 28 January 2012 - 02:29 AM
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.
#1018
Posted 28 January 2012 - 04:30 PM
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.
#1019
Posted 29 January 2012 - 01:02 AM
#1020
Posted 03 February 2012 - 06:23 AM
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 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users









