efl/src/examples/edje/physics_soft_bodies.edc

198 lines
4.9 KiB
Plaintext

/* This example shows how to use soft bodies.
*
* Soft bodies have an attribute to change how much it will
* deforms when colliding. It's called "hardness", and can
* be set to any value between 0.0 (soft) and 1.0 (hard).
* By default, all the soft bodies are hard (1.0).
*
* This example will make a box and a sphere collide
* many times against the floor and will be placed at
* top of the screen again. They will have their hardness
* modified each time, going from the default to a very
* soft state.
*
* It can be tested with edje_player
* $ edje_player physics_soft_bodies.edj
*/
collections {
images {
image: "bubble-blue.png" COMP;
}
group {
name: "example_group";
parts {
part {
name: "background";
type: RECT;
physics_body: NONE;
description {
state: "default" 0.0;
color: 255 255 255 255; /* white */
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
}
}
part {
name: "red_box";
type: RECT;
physics_body: SOFT_BOX;
description {
state: "default" 0.0;
color: 255 0 0 255; /* red */
rel1.relative: 0.75 0.1;
rel2.relative: 0.95 0.3;
aspect: 1 1;
physics {
ignore_part_pos: 0;
restitution: 0.85;
}
}
description {
state: "soft" 0.0;
inherit: "default" 0.0;
physics {
hardness: 0.8;
}
}
description {
state: "very_soft" 0.0;
inherit: "default" 0.0;
physics {
hardness: 0.4;
}
}
}
part {
name: "blue_circle";
type: IMAGE;
physics_body: SOFT_CYLINDER;
description {
state: "default" 0.0;
rel1.relative: 0.25 0.1;
rel2.relative: 0.45 0.3;
aspect: 1 1;
image {
normal: "bubble-blue.png";
}
physics {
ignore_part_pos: 0;
restitution: 0.85;
hardness: 1;
}
}
description {
state: "soft" 0.0;
inherit: "default" 0.0;
physics.hardness: 0.8;
}
description {
state: "very_soft" 0.0;
inherit: "default" 0.0;
physics.hardness: 0.4;
}
}
part {
name: "floor";
type: RECT;
physics_body: BOUNDARY_BOTTOM;
description {
state: "default" 0.0;
visible: 0;
physics {
restitution: 0.7;
}
}
}
part {
name: "right_wall";
type: RECT;
physics_body: BOUNDARY_RIGHT;
description {
state: "default" 0.0;
visible: 0;
physics {
restitution: 1.0;
}
}
}
part {
name: "left_wall";
type: RECT;
physics_body: BOUNDARY_LEFT;
description {
state: "default" 0.0;
visible: 0;
physics {
restitution: 1.0;
}
}
}
}
programs {
program {
name: "stop,go_soft";
signal: "load";
in: 3 0;
action: PHYSICS_STOP;
target: "red_box";
target: "blue_circle";
after: "go_soft";
}
program {
name: "go_soft";
action: STATE_SET "soft" 0.0;
target: "red_box";
target: "blue_circle";
after: "stop,go_very_soft";
}
program {
name: "stop,go_very_soft";
in: 3 0;
action: PHYSICS_STOP;
target: "red_box";
target: "blue_circle";
after: "go_very_soft";
}
program {
name: "go_very_soft";
action: STATE_SET "very_soft" 0.0;
target: "red_box";
target: "blue_circle";
after: "stop,go_default";
}
program {
name: "stop,go_default";
in: 3 0;
action: PHYSICS_STOP;
target: "red_box";
target: "blue_circle";
after: "go_default";
}
program {
name: "go_default";
action: STATE_SET "default" 0.0;
target: "red_box";
target: "blue_circle";
after: "stop,go_soft";
}
}
}
}