Animate the penguins based on frametime. So that the speed is constant at different e17 fps

SVN revision: 49404
This commit is contained in:
Davide Andreoli 2010-06-02 23:58:38 +00:00
parent 0ba821551f
commit dc3abcbd0f
3 changed files with 25 additions and 23 deletions

View File

@ -506,8 +506,8 @@ _cb_animator(void *data)
// ****** CUSTOM ACTIONS ********
if (tux->custom)
{
tux->x += ((double)tux->custom->h_speed / 100);
tux->y += ((double)tux->custom->v_speed / 100);
tux->x += ((double)tux->custom->h_speed * ecore_animator_frametime_get());
tux->y += ((double)tux->custom->v_speed * ecore_animator_frametime_get());
if (!_is_inside_any_win(pop,
(int)tux->x+(tux->action->w/2),
(int)tux->y+tux->action->h+1,
@ -523,7 +523,7 @@ _cb_animator(void *data)
// ****** FALLER ********
else if (tux->action->id == ID_FALLER)
{
tux->y += ((double)tux->action->speed / 100);
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
if ((touch = _is_inside_any_win(pop,
(int)tux->x+(tux->action->w/2),
(int)tux->y + tux->action->h,
@ -545,7 +545,7 @@ _cb_animator(void *data)
// ****** FLOATER ********
else if (tux->action->id == ID_FLOATER)
{
tux->y += ((double)tux->action->speed / 100);
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
if ((touch = _is_inside_any_win(pop,
(int)tux->x+(tux->action->w/2),
(int)tux->y + tux->action->h,
@ -569,7 +569,9 @@ _cb_animator(void *data)
// left
else if (tux->reverse)
{
tux->x -= ((double)tux->action->speed / 100);
//~ printf("FT: %f\n", edje_frametime_get());
//~ printf("FT: %f\n", pop->frame_speed);
tux->x -= ((double)tux->action->speed * ecore_animator_frametime_get());
if ((touch = _is_inside_any_win(pop, (int)tux->x , (int)tux->y, _RET_RIGHT_VALUE)) ||
tux->x < 0)
{
@ -588,7 +590,7 @@ _cb_animator(void *data)
// right
else
{
tux->x += ((double)tux->action->speed / 100);
tux->x += ((double)tux->action->speed * ecore_animator_frametime_get());
if ((touch = _is_inside_any_win(pop, (int)tux->x + tux->action->w, (int)tux->y, _RET_LEFT_VALUE)) ||
(tux->x + tux->action->w) > pop->width)
{
@ -613,7 +615,7 @@ _cb_animator(void *data)
// ****** FLYER ********
else if (tux->action->id == ID_FLYER)
{
tux->y -= ((double)tux->action->speed / 100);
tux->y -= ((double)tux->action->speed * ecore_animator_frametime_get());
tux->x += (random() % 3) - 1;
if (tux->y < 0)
{
@ -624,7 +626,7 @@ _cb_animator(void *data)
// ****** ANGEL ********
else if (tux->action->id == ID_ANGEL)
{
tux->y -= ((double)tux->action->speed / 100);
tux->y -= ((double)tux->action->speed * ecore_animator_frametime_get());
tux->x += (random() % 3) - 1;
if (tux->y < -100)
_reborn(tux);
@ -632,7 +634,7 @@ _cb_animator(void *data)
// ****** CLIMBER ********
else if (tux->action->id == ID_CLIMBER)
{
tux->y -= ((double)tux->action->speed / 100);
tux->y -= ((double)tux->action->speed * ecore_animator_frametime_get());
// left
if (tux->reverse)
{
@ -671,7 +673,7 @@ _cb_animator(void *data)
// printf("PENGUINS: Place tux at x:%d y:%d w:%d h:%d\n", tux->x, tux->y, tux->action->w, tux->action->h);
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
}
return 1;
return ECORE_CALLBACK_RENEW;
}
static int
@ -893,7 +895,7 @@ _start_bombing_at(Penguin *tux, int at_y)
}
static void
_cb_custom_end (void *data, Evas_Object *o, const char *emi, const char *src)
_cb_custom_end(void *data, Evas_Object *o, const char *emi, const char *src)
{
Penguin* tux = data;
//printf("PENGUINS: Custom action end.\n");

View File

@ -146,14 +146,14 @@ data
* speed: the speed of the movement (not the frame rate)
* acceptable value are from 10 to 1000
*************************************************************/
item: "Faller" "30 30 600"; //600
item: "Floater" "30 30 300"; //600
item: "Walker" "30 30 150"; //90
item: "Climber" "30 30 150";
item: "Faller" "30 30 200";
item: "Floater" "30 30 70";
item: "Walker" "30 30 50";
item: "Climber" "30 30 40";
item: "Bomber" "32 32 0";
item: "Splatter" "30 30 0";
item: "Flyer" "30 30 200";
item: "Angel" "44 30 100"; //This is an optional action
item: "Flyer" "30 30 70";
item: "Angel" "44 30 30"; //This is an optional action
/**************************************************************
* Custom actions definitions.

View File

@ -278,12 +278,12 @@ data
{
item: "PopulationName" "Lemmings";
//item: "<action>" "width height speed";
item: "Walker" "20 20 90"; //90
item: "Faller" "16 20 600"; //600
item: "Climber" "16 32 80"; //80
item: "Floater" "18 32 80";
item: "Splatter" "32 32 80";
item: "Flyer" "18 32 80";
item: "Walker" "20 20 25";
item: "Faller" "16 20 150";
item: "Climber" "16 32 20";
item: "Floater" "18 32 35";
item: "Splatter" "32 32 35";
item: "Flyer" "18 32 35";
item: "Bomber" "64 83 0";
//item: "Custom_x" "width height h_speed v_speed r_min r_max";