From 81283b584a7f7c38b697c438858a8b70294dd276 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 10 May 2014 14:14:08 +1000 Subject: Add physics to the windows. Sure, it's just an annoying gimmick right now, but there's plans for this to be actually useful. --- src/extantz/ephysics_demo.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/extantz/ephysics_demo.c') diff --git a/src/extantz/ephysics_demo.c b/src/extantz/ephysics_demo.c index 6697cc9..4655dbb 100644 --- a/src/extantz/ephysics_demo.c +++ b/src/extantz/ephysics_demo.c @@ -2,8 +2,6 @@ #include -#if USE_PHYSICS - #define EPHYSICS_TEST_THEME "extantz" EPhysics_World *ephysicsAdd(globals *ourGlobals) @@ -34,37 +32,42 @@ EPhysics_World *ephysicsAdd(globals *ourGlobals) ephysics_body_restitution_set(boundary, 1); ephysics_body_friction_set(boundary, 0); - box1 = elm_image_add(ourGlobals->win); sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); - elm_image_file_set(box1, strdup(buf), "blue-cube"); - evas_object_move(box1, ourGlobals->win_w / 2 - 80, ourGlobals->win_h - 200); - evas_object_resize(box1, 70, 70); - evas_object_show(box1); + box1 = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win, + elm_obj_image_file_set(strdup(buf), "blue-cube"), + evas_obj_size_set(70, 70), + evas_obj_position_set(ourGlobals->win_w / 2 - 80, ourGlobals->win_h - 200), + evas_obj_visibility_set(EINA_TRUE) + ); box_body1 = ephysics_body_box_add(world); ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE); ephysics_body_restitution_set(box_body1, 0.7); ephysics_body_friction_set(box_body1, 0); - ephysics_body_linear_velocity_set(box_body1, -150, 200, 0); + ephysics_body_linear_velocity_set(box_body1, -1500, 2000, 0); ephysics_body_angular_velocity_set(box_body1, 0, 0, 36); ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1); + eo_unref(box1); + - box2 = elm_image_add(ourGlobals->win); - elm_image_file_set(box2, strdup(buf), "purple-cube"); - evas_object_move(box2, ourGlobals->win_w / 2 + 10, ourGlobals->win_h - 200); - evas_object_resize(box2, 70, 70); - evas_object_show(box2); + sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); + box2 = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win, + elm_obj_image_file_set(strdup(buf), "purple-cube"), + evas_obj_size_set(70, 70), + evas_obj_position_set(ourGlobals->win_w / 2 + 10, ourGlobals->win_h - 200), + evas_obj_visibility_set(EINA_TRUE) + ); box_body2 = ephysics_body_box_add(world); ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE); ephysics_body_restitution_set(box_body2, 0.7); ephysics_body_friction_set(box_body2, 0); - ephysics_body_linear_velocity_set(box_body2, 80, -60, 0); + ephysics_body_linear_velocity_set(box_body2, 800, -600, 0); ephysics_body_angular_velocity_set(box_body2, 0, 0, 360); ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1); + eo_unref(box2); ephysics_world_gravity_set(world, 0, 0, 0); return world; } -#endif -- cgit v1.1