aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/ephysics_demo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/extantz/ephysics_demo.c')
-rw-r--r--src/extantz/ephysics_demo.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/extantz/ephysics_demo.c b/src/extantz/ephysics_demo.c
new file mode 100644
index 0000000..e3aa62f
--- /dev/null
+++ b/src/extantz/ephysics_demo.c
@@ -0,0 +1,69 @@
1#include "extantz.h"
2
3
4#if USE_PHYSICS
5
6#define EPHYSICS_TEST_THEME "extantz"
7
8EPhysics_World *ephysicsAdd(GLData *gld)
9{
10 EPhysics_Body *boundary;
11 EPhysics_World *world;
12 EPhysics_Body *box_body1, *box_body2;
13 Evas_Object *box1, *box2;
14 char buf[PATH_MAX];
15
16 // ePhysics stuff.
17 world = ephysics_world_new();
18 ephysics_world_render_geometry_set(world, 0, 0, -50, gld->win_w, gld->win_h, 100);
19
20 boundary = ephysics_body_bottom_boundary_add(world);
21 ephysics_body_restitution_set(boundary, 1);
22 ephysics_body_friction_set(boundary, 0);
23
24 boundary = ephysics_body_top_boundary_add(world);
25 ephysics_body_restitution_set(boundary, 1);
26 ephysics_body_friction_set(boundary, 0);
27
28 boundary = ephysics_body_left_boundary_add(world);
29 ephysics_body_restitution_set(boundary, 1);
30 ephysics_body_friction_set(boundary, 0);
31
32 boundary = ephysics_body_right_boundary_add(world);
33 ephysics_body_restitution_set(boundary, 1);
34 ephysics_body_friction_set(boundary, 0);
35
36 box1 = elm_image_add(gld->win);
37 sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME);
38 elm_image_file_set(box1, strdup(buf), "blue-cube");
39 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200);
40 evas_object_resize(box1, 70, 70);
41 evas_object_show(box1);
42
43 box_body1 = ephysics_body_box_add(world);
44 ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE);
45 ephysics_body_restitution_set(box_body1, 0.7);
46 ephysics_body_friction_set(box_body1, 0);
47 ephysics_body_linear_velocity_set(box_body1, -150, 200, 0);
48 ephysics_body_angular_velocity_set(box_body1, 0, 0, 36);
49 ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1);
50
51 box2 = elm_image_add(gld->win);
52 elm_image_file_set(box2, strdup(buf), "purple-cube");
53 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200);
54 evas_object_resize(box2, 70, 70);
55 evas_object_show(box2);
56
57 box_body2 = ephysics_body_box_add(world);
58 ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE);
59 ephysics_body_restitution_set(box_body2, 0.7);
60 ephysics_body_friction_set(box_body2, 0);
61 ephysics_body_linear_velocity_set(box_body2, 80, -60, 0);
62 ephysics_body_angular_velocity_set(box_body2, 0, 0, 360);
63 ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1);
64
65 ephysics_world_gravity_set(world, 0, 0, 0);
66
67 return world;
68}
69#endif