3

I'm new to Game Maker. I've created the mechanics of a little physics based game, and I've used the methods outlined in YoYo Games' tutorial to create complex physics objects (http://www.yoyogames.com/blog/70). To get going quickly I've used physics_world_draw_debug to draw my objects (http://www.yoyogames.com/blog/71), thinking it would be easy (as almost every other thing in Game Maker) to switch to "real" drawing of the polygons.

My code is looking kinda like this (copied from the tutorial):

var fixture = physics_fixture_create();
physics_fixture_set_polygon_shape(fixture);

// four points, making up a convex shape
physics_fixture_add_point(fixture, x0, y0);
physics_fixture_add_point(fixture, x1, y1);
physics_fixture_add_point(fixture, x2, y2);
physics_fixture_add_point(fixture, x3, y3);

physics_fixture_set_density(fixture, 0.8);
physics_fixture_set_restitution(fixture, 0.1);
physics_fixture_set_linear_damping(fixture, 0.5);
physics_fixture_set_angular_damping(fixture, 0.5);
physics_fixture_set_friction(fixture, 0.5);
physics_fixture_bind(fixture, id);
physics_fixture_delete(fixture);

This code is run several times for each object, with different x and y values.

But I can't find a way to query a physics object of the current state of its fixtures. I probably could save a copy of the coordinates of all the points making up my fixtures, for each and every object, but then I would have to do all the math too, rotating them and translating them. Essentially doing the same work as physics_world_draw_debug.

Is there an easier way to draw physics objects made up of several fixtures? Either by getting the current coordinates or by calling some builtin draw_fixture_with_color function or something like that?

Peter Jaric
  • 5,162
  • 3
  • 30
  • 42

1 Answers1

0

I cross-posted this question on the YoYoGames forum and received these two answers:

1) By flyingsaucerinvasion:

Try the other function, physics_draw_debug, or use "d3d_transform rotation and translation".

Full answer here: https://forum.yoyogames.com/index.php?threads/how-can-i-access-the-physics-fixtures-in-order-to-draw-them.3399/#post-25899

2) By Yal:

Use simple objects represented with sprites, and join them together with joints.

Full answer here: https://forum.yoyogames.com/index.php?threads/how-can-i-access-the-physics-fixtures-in-order-to-draw-them.3399/#post-28429

Peter Jaric
  • 5,162
  • 3
  • 30
  • 42