Jump to content


Photo

Extremephysics - 2d Physics Engine For Game Maker


  • Please log in to reply
1144 replies to this topic

#1081 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 03 June 2012 - 07:19 PM

i tried with the .gex file and it didn't threw the error, and i tried with the dll but this didn't work... maybe i did something wrong ( i'm new to game maker), so i would prefer using the .gex ( it's much simpler... :whistle: ) the described problem was with the .gex.
ps: it would be very useful if you could host a working testbed file for studio

That sounds like a bug in Studio ... I don't have Studio, so I can't really help you, sorry.

I saw your example on your site but I don't understand how you made the polygon a model. Could I have some help as to how to do it?

What example do you mean? Why do you want to create a model?
  • 0

#1082 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 04 June 2012 - 07:18 PM

I don't want to create a model. I just want to add a texture to the polygons (boxchains), that's all. In the code below you say that it's for performance, that's why I thought I'd make it a model. Here's the code you posted on your website a while back:

// subdivide the polygon
ep_world_multipoly_begin(global.world, vertices);
for(i = 0; i<vertices; i += 1) {
    ep_world_multipoly_set_vertex(global.world, i, vertex_x[i], vertex_y[i]);
}
if !ep_world_multipoly_end(global.world, false) {
    exit;
}
first_poly = ep_world_multipoly_get_first(global.world);
last_poly = ep_world_multipoly_get_last(global.world);
polys = last_poly-first_poly+1;

// create 3d model (for performance)
w = background_get_width(bg_tex_solid);
h = background_get_height(bg_tex_solid);
model = d3d_model_create();
for(i = 0; i<polys; i += 1) {
    c = ep_polygon_get_vertex_count(global.world, first_poly+i);
    d3d_model_primitive_begin(model, pr_trianglefan);
    for(j = 0; j<c; j += 1) {
        xx = ep_polygon_get_vertex_x(global.world, first_poly+i, j);
        yy = ep_polygon_get_vertex_y(global.world, first_poly+i, j);
        d3d_model_vertex_texture(model, xx-0.5, yy-0.5, 0, xx/w, yy/h);
    }
    d3d_model_primitive_end(model);
}
for(i = first_poly; i<=last_poly; i += 1) {
    ep_polygon_destroy(global.world, i);
}

Edited by Mr.Troid, 04 June 2012 - 07:18 PM.

  • 0

#1083 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 06 June 2012 - 03:24 PM

Can you post the code you are using to create the box chain?
  • 0

#1084 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 07 June 2012 - 01:10 AM

Sure, it's straight out of your 'rolling_ball' example:

var i;

global.world_id = ep_world_create();
ep_world_set_settings(global.world_id, 1/2, 15, 10, 0.1, 0.5, 0, 0.5, 1);
body_id = ep_body_create_static(global.world_id);

ep_body_boxchain_begin(global.world_id, body_id, instance_number(ob_marker));
i = 0;
with ob_marker {
    ep_body_boxchain_set_vertex(global.world_id, other.body_id, i, x, y);
    i += 1;
};
ep_body_boxchain_end(global.world_id, body_id, false, false, 0, 40, 0);
for(i = ep_body_boxchain_get_first(global.world_id, body_id); i<=ep_body_boxchain_get_last(global.world_id, body_id); i += 1) {
    ep_shape_set_collision(global.world_id, body_id, i, 1, 1, 0);
    ep_shape_set_material(global.world_id, body_id, i, 0.2, 0.8, 0, 0);
};

  • 0

#1085 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 08 June 2012 - 11:11 AM

Try this:
var ww, hh, i, c, nx1, ny1, nx2, ny2, d1, d2, a, xx, yy, boxchain_x, boxchain_y;

ww = 256; // width of texture
hh = 256; // height of texture

i = 0;
with ob_marker {
	boxchain_x[i] = x;
	boxchain_y[i] = y;
	i += 1;
};
c = i;

model = d3d_model_create();
d3d_model_primitive_begin(model, pr_trianglestrip);
for(i = 0; i < c; i += 1) {
	if(i = 0) {
		nx1 = boxchain_y[i + 1] - boxchain_y[i];
		ny1 = boxchain_x[i] - boxchain_x[i + 1];
	} else {
		nx1 = boxchain_y[i] - boxchain_y[i - 1];
		ny1 = boxchain_x[i - 1] - boxchain_x[i];
	}
	if(i = c - 1) {
		nx2 = boxchain_y[i] - boxchain_y[i - 1];
		ny2 = boxchain_x[i - 1] - boxchain_x[i];
	} else {
		nx2 = boxchain_y[i + 1] - boxchain_y[i];
		ny2 = boxchain_x[i] - boxchain_x[i + 1];
	}
	d1 = sqrt(nx1 * nx1 + ny1 * ny1);
	d2 = sqrt(nx2 * nx2 + ny2 * ny2);
	nx1 /= d1;
	ny1 /= d1;
	nx2 /= d2;
	ny2 /= d2;
	a = 40 / (1 + nx1 * nx2 + ny1 * ny2);
	xx = boxchain_x[i] - nx1 * a - nx2 * a;
	yy = boxchain_y[i] - ny1 * a - ny2 * a;
	d3d_model_vertex_texture(model, xx, yy, xx / ww, yy / hh);
	d3d_model_vertex_texture(model, boxchain_x[i], boxchain_y[i], boxchain_x[i] / ww, boxchain_y[i] / hh);
}
d3d_model_primitive_end(model);
(not tested)

Edited by Maarten Baert, 10 June 2012 - 12:21 PM.

  • 0

#1086 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 08 June 2012 - 04:37 PM

Thanks. I'll try it out now.

I get this.


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

Error in code at line 30:
                   nx1 = boxchain_y[i + 1] - boxchain_y[i];
                         ^
at position 24: Unknown variable boxchain_y or array index out of bounds


Edited by Mr.Troid, 08 June 2012 - 05:57 PM.

  • 0

#1087 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 10 June 2012 - 12:20 PM

Replace the first line with this:
var ww, hh, i, c, nx1, ny1, nx2, ny2, d1, d2, a, xx, yy, boxchain_x, boxchain_y;

  • 0

#1088 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 11 June 2012 - 02:26 AM

That's the same thing.

Ya know what? I'll just do it the easy way because finding the right position and angle for each boxchain won't be so quick. Also, if I make the marker too high then the polygon will be long and way too steep. Then, I'd have to apply the right amount of force for the player to get over it. If the markers are too low and closer together then the floor will be too 'straight-forward' and boring. I could gradually raise the positions of the markers in the editor but that will mean horizontally longer rooms. So, I'll just make 64*64 objects (including polygons), a 64*64 sprite that will be drawn over each object (Like a tile, only more manipulable). Then, in the Room Creation event specify which index of the sprite I wanna draw on it. I think that should work. That's gonna take a while but at least I'll get it done.

Edited by Mr.Troid, 11 June 2012 - 04:09 AM.

  • 0

#1089 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 12 June 2012 - 02:02 AM

I should have just posted this from the beginning. I'm merging the walls which works perfectly.
// merge walls
var a, merge;
with (obj_poly_block_static1) {
	a = instance_create(x-32, y-32, obj_wallbox);
	a.w = 64;
	a.h = 64;
};
do {
	merge = false;
	with (obj_wallbox) {
    	with (obj_wallbox) {
        	if x = other.x+other.w and y = other.y and h = other.h {
            	other.w += w;
            	merge = true;
            	instance_destroy();
        	}
    	}
	}
} until (merge = false);
do {
	merge = false;
	with (obj_wallbox) {
    	with (obj_wallbox) {
        	if y = other.y+other.h and x = other.x and w = other.w {
            	other.h += h;
            	merge = true;
            	instance_destroy();
        	}
    	}
	}
} until (merge = false);
with (obj_wallbox) {
	body_id = ep_body_create_static(global.world_id);
	shape_id = ep_shape_create_box(global.world_id, body_id, w, h, w/2, h/2, 0, 1);
	ep_shape_set_collision(global.world_id, body_id, shape_id, collide1a, collide1b, 0);
	ep_shape_set_material(global.world_id, body_id, shape_id, 0.2, 0.6, 0, 0);
	physics_object_set(body_id);
};

But I'm trying to check for collision but I can't put the code below because there is no code that initiates body_id in 'obj_wallbox', when I press the jump key nothing happens:
with (obj_wallbox)  {
  for (s = ep_body_first_shape(global.world_id, body_id); s != 0; s = ep_shape_next(global.world_id, body_id, s)) {
    	if ep_shape_collision_test_box(global.world_id, body_id, s, 64, 64, x, y+2, 0, -0.1) {
        	collision_down_box = 1;
    	};
  };
};

if (k_jump) = 1 and (collision_down_box) {
	y_vel = -jump_force;
};

Got any ideas on how to fix it?

Edited by Mr.Troid, 12 June 2012 - 02:12 PM.

  • 0

#1090 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 12 June 2012 - 02:31 PM

Why don't you use ep_world_collision_test_box? It's easier and a lot faster. If you only want to check collisions with walls instead of all bodies, change the collision mask of the walls:
ep_shape_set_collision(global.world_id, body_id, shape_id, collide1a|2, collide1b, 0);
Now use this to check collisions:
ep_world_collision_test_box(world_id, w, h, x, y, rot, contact_threshold, 0, 2, 0)
(assuming you're not using collision mask 2 yet)
  • 0

#1091 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 12 June 2012 - 03:13 PM

I got a question, when you combine the walls and make it one polygon, don't you change the shape of the polygon too? Will I still be able to check for 64 pixels?

Edited by Mr.Troid, 12 June 2012 - 03:37 PM.

  • 0

#1092 pablo1517

pablo1517

    GMC Member

  • New Member
  • 67 posts

Posted 14 June 2012 - 12:57 AM

Please, does anyone have or can make an example of how to make a rope? Something like whip or even a rope to hang on it. Anything rope-ish - PLZ PLZ PLZ :<
  • 0

#1093 mnm_manish

mnm_manish

    GMC Member

  • GMC Member
  • 63 posts
  • Version:GM8

Posted 14 June 2012 - 01:00 PM

:thumbsup:
Thanx Maarten ..
I have browsed your programs like
-Model Creator
-Extreme Physics
-HTTP Dll
-GM Binary
-ds_grid
-C Math
And Some Others I Forgot ..
Its pretty good but I dont know you are providing open source programs
and you may be a novice++ GM Programmer . But are not you making any Games
from GM. And Another thing i like to get the source code of user_is_admin.dll.
Please have a pity. :GM8: From ManishKarki
mnm_manish
  • 0

#1094 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 15 June 2012 - 03:58 PM

I got a question, when you combine the walls and make it one polygon, don't you change the shape of the polygon too? Will I still be able to check for 64 pixels?

What do you mean? It's not a polygon but a box shape, and yes, the shape does change of course, that's the whole idea of merging the walls :).

Please, does anyone have or can make an example of how to make a rope? Something like whip or even a rope to hang on it. Anything rope-ish - PLZ PLZ PLZ :<

Take a look at rope.gmk :).

:thumbsup:
Thanx Maarten ..
I have browsed your programs like
-Model Creator
-Extreme Physics
-HTTP Dll
-GM Binary
-ds_grid
-C Math
And Some Others I Forgot ..
Its pretty good but I dont know you are providing open source programs
and you may be a novice++ GM Programmer . But are not you making any Games
from GM. And Another thing i like to get the source code of user_is_admin.dll.
Please have a pity. :GM8: From ManishKarki
mnm_manish

Uhm ... what exactly is the question?

I've made some games, one is in my signature. Most of my games aren't on this forum though (you can find some more here).

The source of user_is_admin.dll: http://pastebin.com/cQXDzRfJ
  • 0

#1095 Mr.Troid

Mr.Troid

    GMC Member

  • New Member
  • 114 posts

Posted 15 June 2012 - 05:18 PM

It's not a polygon but a box shape...


A square ('box') is a polygon. But in your engine it's probably different when you create a box, you don't refer to as a square. Thanks for the help.

Edited by Mr.Troid, 15 June 2012 - 05:40 PM.

  • 0

#1096 Zombifier

Zombifier

    GMC Member

  • GMC Member
  • 6 posts
  • Version:GM8

Posted 17 June 2012 - 01:31 AM

I made a ragdoll demo for ExtremePhysics. It works great, I ran into a few problems, but don't worry, I fixed them. Enjoy guys!
Credits are in the game information.

http://sandbox.yoyog...-ragdoll-engine

Use the "N" button to create a ragdoll at mouse position. This is basically the ragdoll demo in testbed.gmk, but with sprites, and it works really great! They all seem a little stiff though, but that should be easy to fix by messing with the variables in the object "obj_ragdoll".

Included scripts with their syntaxes:
make_ragdoll(world,x,y)
apply_force(world,part,forcex,forcey)

-TZK

Edited by Zombifier, 17 June 2012 - 02:12 AM.

  • 0

#1097 huh?

huh?

    GMC Member

  • New Member
  • 426 posts
  • Version:Unknown

Posted 26 June 2012 - 06:29 PM

Wow, really great work on this!

I've got a (hopefully) quick question though, if you're not too busy: How would I go about changing the gravity of water particles (in the fluids example) that have already been created? I've tried using ep_body_set_gravity() but that only works on newly created water particles. I assume it's because they're in a ds_list...?
  • 0

#1098 Maarten Baert

Maarten Baert

    GMC Member

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

Posted 27 June 2012 - 11:35 PM

I've tried using ep_body_set_gravity() but that only works on newly created water particles. I assume it's because they're in a ds_list...?

That should work, but you have to call that function for every particle in the list.
  • 0

#1099 Southman

Southman

    I simply am not here

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

Posted 18 July 2012 - 03:41 PM

How do you use the joints?
I'm trying to have one object dangle from another object, and I can't get it to work.
  • 0

#1100 xsonicvision

xsonicvision

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 18 July 2012 - 06:59 PM

Hi there, I have a question, and i need a little help. I've just started using extremephysics, I think its amazing, I'm just not very familiar with the language. For the rolling ball example, i would like to set the angle of the sprite to the angle of the floor, or to the angle at which the ball is moving. I've also noticed on the testbed example in test number two (and all other tests i believe) when i activate the drawing debug for velocity, in pink it shows me the angle that im looking for, but i can't seem to figure out which variable it is?? Can some one help me please?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users