more cleanups, mainly whitespace, indentation and code style... now I can start working on this :)
This commit is contained in:
parent
918e24c97a
commit
88fcb3b9f7
|
@ -38,10 +38,9 @@ e_int_config_penguins_module(E_Comp *comp, const char *params)
|
||||||
v->basic.create_widgets = _basic_create_widgets;
|
v->basic.create_widgets = _basic_create_widgets;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/e-module-penguins.edj", e_module_dir_get(pop->module));
|
snprintf(buf, sizeof(buf), "%s/e-module-penguins.edj", e_module_dir_get(pop->module));
|
||||||
cfd = e_config_dialog_new(comp,
|
cfd = e_config_dialog_new(comp, D_("Population Settings"),
|
||||||
D_("Population Settings"),
|
"Penguins", "appearance/penguins",
|
||||||
"Penguins", "appearance/penguins",
|
buf, 0, v, pop);
|
||||||
buf, 0, v, pop);
|
|
||||||
pop->config_dialog = cfd;
|
pop->config_dialog = cfd;
|
||||||
return cfd;
|
return cfd;
|
||||||
}
|
}
|
||||||
|
@ -76,8 +75,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
pop = cfd->data;
|
pop = cfd->data;
|
||||||
pop->config_dialog = NULL;
|
pop->config_dialog = NULL;
|
||||||
eina_stringshare_del(cfdata->theme);
|
eina_stringshare_del(cfdata->theme);
|
||||||
free(cfdata);
|
E_FREE(cfdata);
|
||||||
cfdata = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
|
@ -85,6 +83,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
{
|
{
|
||||||
Evas_Object *o, *ob, *ol;
|
Evas_Object *o, *ob, *ol;
|
||||||
Penguins_Population *pop;
|
Penguins_Population *pop;
|
||||||
|
Eina_List *l;
|
||||||
|
int count = 0;
|
||||||
|
char *theme;
|
||||||
|
|
||||||
pop = cfd->data;
|
pop = cfd->data;
|
||||||
o = e_widget_list_add(evas, 0, 0);
|
o = e_widget_list_add(evas, 0, 0);
|
||||||
|
@ -104,37 +105,25 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
ob = e_widget_slider_add(evas, 1, 0, D_("%1.0f"), 50, 255, 1, 0, NULL, &(cfdata->alpha), 200);
|
ob = e_widget_slider_add(evas, 1, 0, D_("%1.0f"), 50, 255, 1, 0, NULL, &(cfdata->alpha), 200);
|
||||||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||||
|
|
||||||
//Lista
|
|
||||||
ob = e_widget_label_add(evas, D_("Select population:"));
|
ob = e_widget_label_add(evas, D_("Select population:"));
|
||||||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||||
ol = e_widget_ilist_add(evas, 24, 24, &(cfdata->theme));
|
ol = e_widget_ilist_add(evas, 24, 24, &(cfdata->theme));
|
||||||
|
|
||||||
e_widget_ilist_clear(ol);
|
EINA_LIST_FOREACH(pop->themes, l, theme)
|
||||||
|
|
||||||
Eina_List *l;
|
|
||||||
int count;
|
|
||||||
l = pop->themes;
|
|
||||||
count = 0;
|
|
||||||
while (l)
|
|
||||||
{
|
{
|
||||||
char *theme;
|
char *name = edje_file_data_get(theme, "PopulationName");
|
||||||
char *name;
|
|
||||||
Evas_Object *oi;
|
Evas_Object *oi;
|
||||||
theme = l->data;
|
|
||||||
name = edje_file_data_get(theme, "PopulationName");
|
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
oi = edje_object_add(evas);
|
oi = edje_object_add(evas);
|
||||||
edje_object_file_set(oi, theme, "icon");
|
edje_object_file_set(oi, theme, "icon");
|
||||||
//printf("TEMA: %s (%s)\n", name, cfdata->theme);
|
|
||||||
e_widget_ilist_append(ol, oi, name, NULL, theme, theme);
|
e_widget_ilist_append(ol, oi, name, NULL, theme, theme);
|
||||||
if (strcmp(theme, cfdata->theme) == 0)
|
if (!strcmp(theme, cfdata->theme))
|
||||||
{
|
|
||||||
e_widget_ilist_selected_set(ol, count);
|
e_widget_ilist_selected_set(ol, count);
|
||||||
}
|
free(name);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
l = eina_list_next(l);
|
|
||||||
}
|
}
|
||||||
e_widget_ilist_go(ol);
|
e_widget_ilist_go(ol);
|
||||||
e_widget_size_min_set(ol, 155, 250);
|
e_widget_size_min_set(ol, 155, 250);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#define ID_ANGEL 8
|
#define ID_ANGEL 8
|
||||||
|
|
||||||
|
|
||||||
//_RAND(prob) is true one time every prob
|
// _RAND(prob) is true one time every prob
|
||||||
#define _RAND(prob) ( ( random() % prob ) == 0 )
|
#define _RAND(prob) ( ( random() % prob ) == 0 )
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,31 +190,31 @@ _population_free(Penguins_Population *pop)
|
||||||
pop->actions = NULL;
|
pop->actions = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Penguins_Action *
|
static Penguins_Action *
|
||||||
_load_action(Penguins_Population *pop, const char *filename, char *name, int id)
|
_load_action(Penguins_Population *pop, const char *filename, char *name, int id)
|
||||||
{
|
{
|
||||||
Penguins_Action *act;
|
Penguins_Action *act;
|
||||||
|
int w, h, speed, ret;
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
data = edje_file_data_get(filename, name);
|
data = edje_file_data_get(filename, name);
|
||||||
if (!data) return NULL;
|
if (!data) return NULL;
|
||||||
|
|
||||||
|
ret = sscanf(data, "%d %d %d", &w, &h, &speed);
|
||||||
|
free(data);
|
||||||
|
if (ret != 3) return NULL;
|
||||||
|
|
||||||
act = E_NEW(Penguins_Action, 1);
|
act = E_NEW(Penguins_Action, 1);
|
||||||
if (!act) return NULL;
|
if (!act) return NULL;
|
||||||
|
|
||||||
act->name = strdup(name);
|
act->name = strdup(name);
|
||||||
sscanf(data, "%d %d %d", &act->w, &act->h, &act->speed);
|
|
||||||
|
|
||||||
act->w = act->w * pop->conf->zoom;
|
|
||||||
act->h = act->h * pop->conf->zoom;
|
|
||||||
act->speed = act->speed * pop->conf->zoom;
|
|
||||||
act->id = id;
|
act->id = id;
|
||||||
|
act->w = w * pop->conf->zoom;
|
||||||
|
act->h = h * pop->conf->zoom;
|
||||||
|
act->speed = speed * pop->conf->zoom;
|
||||||
|
|
||||||
if (!pop->actions)
|
if (!pop->actions)
|
||||||
pop->actions = eina_hash_string_small_new(NULL);
|
pop->actions = eina_hash_string_small_new(NULL);
|
||||||
|
|
||||||
eina_hash_add(pop->actions, name, act);
|
eina_hash_add(pop->actions, name, act);
|
||||||
|
|
||||||
return act;
|
return act;
|
||||||
|
@ -224,41 +224,40 @@ static Penguins_Custom_Action *
|
||||||
_load_custom_action(Penguins_Population *pop, const char *filename, char *name)
|
_load_custom_action(Penguins_Population *pop, const char *filename, char *name)
|
||||||
{
|
{
|
||||||
Penguins_Custom_Action *c;
|
Penguins_Custom_Action *c;
|
||||||
|
int w, h, h_speed, v_speed, r_min, r_max, ret;
|
||||||
char *data;
|
char *data;
|
||||||
char buf[25];
|
char buf[25];
|
||||||
|
|
||||||
data = edje_file_data_get(filename, name); // TODO free data??
|
data = edje_file_data_get(filename, name);
|
||||||
if (!data) return NULL;
|
if (!data) return NULL;
|
||||||
|
|
||||||
|
ret = sscanf(data, "%d %d %d %d %d %d",
|
||||||
|
&w, &h, &h_speed, &v_speed, &r_min, &r_max);
|
||||||
|
free(data);
|
||||||
|
if (ret != 6) return NULL;
|
||||||
|
|
||||||
c = E_NEW(Penguins_Custom_Action, 1);
|
c = E_NEW(Penguins_Custom_Action, 1);
|
||||||
if (!c) return NULL;
|
if (!c) return NULL;
|
||||||
|
|
||||||
c->name = strdup(name);
|
c->name = strdup(name);
|
||||||
sscanf(data, "%d %d %d %d %d %d",
|
c->w = w * pop->conf->zoom;
|
||||||
&c->w, &c->h, &c->h_speed, &c->v_speed, &c->r_min, &c->r_max);
|
c->h = h * pop->conf->zoom;
|
||||||
|
c->h_speed = h_speed * pop->conf->zoom;
|
||||||
|
c->v_speed = v_speed * pop->conf->zoom;
|
||||||
|
c->r_min = r_min;
|
||||||
|
c->r_max = r_max;
|
||||||
|
|
||||||
c->w = c->w * pop->conf->zoom;
|
pop->custom_num++;
|
||||||
c->h = c->h * pop->conf->zoom;
|
snprintf(buf, sizeof(buf), "start_custom_%d_left", pop->custom_num);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "start_custom_%d_left", pop->custom_num+1);
|
|
||||||
c->left_program_name = strdup(buf);
|
c->left_program_name = strdup(buf);
|
||||||
snprintf(buf, sizeof(buf), "start_custom_%d_right", pop->custom_num+1);
|
snprintf(buf, sizeof(buf), "start_custom_%d_right", pop->custom_num);
|
||||||
c->right_program_name = strdup(buf);
|
c->right_program_name = strdup(buf);
|
||||||
|
|
||||||
pop->customs = eina_list_append(pop->customs, c);
|
pop->customs = eina_list_append(pop->customs, c);
|
||||||
pop->custom_num++;
|
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
|
||||||
hash_fn(const Eina_Hash *hash, const char *key, void *data, void *fdata)
|
|
||||||
{
|
|
||||||
Penguins_Action *a = data;
|
|
||||||
printf("PENGUINS: Load action: '%s' w:%d h:%d speed:%d\n", key, a->w, a->h, a->speed);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_theme_load(Penguins_Population *pop)
|
_theme_load(Penguins_Population *pop)
|
||||||
{
|
{
|
||||||
|
@ -271,10 +270,10 @@ _theme_load(Penguins_Population *pop)
|
||||||
pop->custom_num = 0;
|
pop->custom_num = 0;
|
||||||
|
|
||||||
name = edje_file_data_get(pop->conf->theme, "PopulationName");
|
name = edje_file_data_get(pop->conf->theme, "PopulationName");
|
||||||
if (!name)
|
if (!name) return;
|
||||||
return;
|
|
||||||
|
|
||||||
//printf("PENGUINS: Load theme: %s (%s)\n", name, pop->conf->theme);
|
//printf("PENGUINS: Load theme: %s (%s)\n", name, pop->conf->theme);
|
||||||
|
free(name);
|
||||||
|
|
||||||
// load standard actions
|
// load standard actions
|
||||||
_load_action(pop, pop->conf->theme, "Walker", ID_WALKER);
|
_load_action(pop, pop->conf->theme, "Walker", ID_WALKER);
|
||||||
|
@ -291,15 +290,6 @@ _theme_load(Penguins_Population *pop)
|
||||||
snprintf(buf, sizeof(buf), "Custom_1");
|
snprintf(buf, sizeof(buf), "Custom_1");
|
||||||
while (_load_custom_action(pop, pop->conf->theme, buf))
|
while (_load_custom_action(pop, pop->conf->theme, buf))
|
||||||
snprintf(buf, sizeof(buf), "Custom_%d", i++);
|
snprintf(buf, sizeof(buf), "Custom_%d", i++);
|
||||||
|
|
||||||
// eina_hash_foreach(pop->actions, hash_fn, NULL);
|
|
||||||
// Eina_List *l;
|
|
||||||
// for (l = pop->customs; l; l = l->next )
|
|
||||||
// {
|
|
||||||
// Custom_Action *c = l->data;
|
|
||||||
// printf("PENGUINS: Load custom action: name:'%s' w:%d h:%d h_speed:%d v_speed:%d\n",
|
|
||||||
// c->name, c->w, c->h, c->h_speed, c->v_speed);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -321,12 +311,11 @@ _population_load(Penguins_Population *pop)
|
||||||
o = edje_object_add(pop->canvas);
|
o = edje_object_add(pop->canvas);
|
||||||
edje_object_file_set(o, pop->conf->theme, "anims");
|
edje_object_file_set(o, pop->conf->theme, "anims");
|
||||||
|
|
||||||
tux->action = eina_hash_find(pop->actions,"Faller");
|
tux->action = eina_hash_find(pop->actions, "Faller");
|
||||||
|
|
||||||
evas_object_image_alpha_set(o, 0.5);
|
|
||||||
evas_object_color_set(o, pop->conf->alpha, pop->conf->alpha,
|
evas_object_color_set(o, pop->conf->alpha, pop->conf->alpha,
|
||||||
pop->conf->alpha, pop->conf->alpha);
|
pop->conf->alpha, pop->conf->alpha);
|
||||||
evas_object_pass_events_set(o, 0);
|
evas_object_pass_events_set(o, EINA_FALSE);
|
||||||
|
|
||||||
edje_object_signal_callback_add(o,"click_l","penguins", _cb_click_l, tux);
|
edje_object_signal_callback_add(o,"click_l","penguins", _cb_click_l, tux);
|
||||||
edje_object_signal_callback_add(o,"click_r","penguins", _cb_click_r, tux);
|
edje_object_signal_callback_add(o,"click_r","penguins", _cb_click_r, tux);
|
||||||
|
@ -345,8 +334,6 @@ _delay_born(void *data)
|
||||||
{
|
{
|
||||||
Penguins_Actor *tux = data;
|
Penguins_Actor *tux = data;
|
||||||
|
|
||||||
if (!tux) return ECORE_CALLBACK_CANCEL;
|
|
||||||
|
|
||||||
tux->pop->penguins = eina_list_append(tux->pop->penguins, tux);
|
tux->pop->penguins = eina_list_append(tux->pop->penguins, tux);
|
||||||
_reborn(tux);
|
_reborn(tux);
|
||||||
|
|
||||||
|
@ -360,12 +347,14 @@ _cb_click_l (void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
//printf("Left-click on TUX !!!\n");
|
//printf("Left-click on TUX !!!\n");
|
||||||
_start_bombing_at(tux, tux->y + tux->action->h);
|
_start_bombing_at(tux, tux->y + tux->action->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_click_r (void *data, Evas_Object *o, const char *emi, const char *src)
|
_cb_click_r (void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
{
|
{
|
||||||
//printf("Right-click on TUX !!!\n");
|
//printf("Right-click on TUX !!!\n");
|
||||||
e_int_config_penguins_module(NULL, NULL);
|
e_int_config_penguins_module(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_click_c (void *data, Evas_Object *o, const char *emi, const char *src)
|
_cb_click_c (void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
{
|
{
|
||||||
|
@ -379,11 +368,10 @@ _reborn(Penguins_Actor *tux)
|
||||||
tux->reverse = random() % (2);
|
tux->reverse = random() % (2);
|
||||||
tux->x = random() % (tux->pop->width);
|
tux->x = random() % (tux->pop->width);
|
||||||
tux->y = -100;
|
tux->y = -100;
|
||||||
tux->custom = 0;
|
tux->custom = NULL;
|
||||||
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||||
_start_falling_at(tux, tux->x);
|
_start_falling_at(tux, tux->x);
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
|
||||||
evas_object_show(tux->obj);
|
evas_object_show(tux->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,21 +387,21 @@ _cb_animator(void *data)
|
||||||
Penguins_Actor *tux;
|
Penguins_Actor *tux;
|
||||||
int touch;
|
int touch;
|
||||||
tux = l->data;
|
tux = l->data;
|
||||||
|
|
||||||
// ****** CUSTOM ACTIONS ********
|
// ****** CUSTOM ACTIONS ********
|
||||||
if (tux->custom)
|
if (tux->custom)
|
||||||
{
|
{
|
||||||
tux->x += ((double)tux->custom->h_speed * ecore_animator_frametime_get());
|
tux->x += ((double)tux->custom->h_speed * ecore_animator_frametime_get());
|
||||||
tux->y += ((double)tux->custom->v_speed * ecore_animator_frametime_get());
|
tux->y += ((double)tux->custom->v_speed * ecore_animator_frametime_get());
|
||||||
if (!_is_inside_any_win(pop,
|
if ((!_is_inside_any_win(pop,
|
||||||
(int)tux->x+(tux->action->w/2),
|
(int)tux->x + (tux->action->w / 2),
|
||||||
(int)tux->y+tux->action->h+1,
|
(int)tux->y + tux->action->h + 1,
|
||||||
RETURN_NONE_VALUE)
|
RETURN_NONE_VALUE))
|
||||||
&& (int)tux->y+tux->action->h+1 < pop->height
|
&& ((int)tux->y + tux->action->h + 1 < pop->height)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
edje_object_signal_callback_del(tux->obj,"custom_done","edje", _cb_custom_end);
|
edje_object_signal_callback_del(tux->obj,"custom_done","edje", _cb_custom_end);
|
||||||
_start_falling_at(tux, (int)tux->x+(tux->action->w/2));
|
_start_falling_at(tux, (int)tux->x + (tux->action->w / 2));
|
||||||
tux->custom = NULL;
|
tux->custom = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,18 +410,18 @@ _cb_animator(void *data)
|
||||||
{
|
{
|
||||||
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
|
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
|
||||||
if ((touch = _is_inside_any_win(pop,
|
if ((touch = _is_inside_any_win(pop,
|
||||||
(int)tux->x+(tux->action->w/2),
|
(int)tux->x + (tux->action->w / 2),
|
||||||
(int)tux->y + tux->action->h,
|
(int)tux->y + tux->action->h,
|
||||||
RETURN_TOP_VALUE)))
|
RETURN_TOP_VALUE)))
|
||||||
{
|
{
|
||||||
if (( (int)tux->y - tux->faller_h) > MAX_FALLER_HEIGHT)
|
if (((int)tux->y - tux->faller_h) > MAX_FALLER_HEIGHT)
|
||||||
_start_splatting_at(tux, touch);
|
_start_splatting_at(tux, touch);
|
||||||
else
|
else
|
||||||
_start_walking_at(tux, touch);
|
_start_walking_at(tux, touch);
|
||||||
}
|
}
|
||||||
else if (( (int)tux->y + tux->action->h ) > pop->height)
|
else if (((int)tux->y + tux->action->h) > pop->height)
|
||||||
{
|
{
|
||||||
if (( (int)tux->y - tux->faller_h) > MAX_FALLER_HEIGHT)
|
if (((int)tux->y - tux->faller_h) > MAX_FALLER_HEIGHT)
|
||||||
_start_splatting_at(tux, pop->height);
|
_start_splatting_at(tux, pop->height);
|
||||||
else
|
else
|
||||||
_start_walking_at(tux, pop->height);
|
_start_walking_at(tux, pop->height);
|
||||||
|
@ -444,12 +432,12 @@ _cb_animator(void *data)
|
||||||
{
|
{
|
||||||
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
|
tux->y += ((double)tux->action->speed * ecore_animator_frametime_get());
|
||||||
if ((touch = _is_inside_any_win(pop,
|
if ((touch = _is_inside_any_win(pop,
|
||||||
(int)tux->x+(tux->action->w/2),
|
(int)tux->x + (tux->action->w / 2),
|
||||||
(int)tux->y + tux->action->h,
|
(int)tux->y + tux->action->h,
|
||||||
RETURN_TOP_VALUE)
|
RETURN_TOP_VALUE)
|
||||||
))
|
))
|
||||||
_start_walking_at(tux, touch);
|
_start_walking_at(tux, touch);
|
||||||
else if (( (int)tux->y + tux->action->h ) > pop->height)
|
else if (((int)tux->y + tux->action->h) > pop->height)
|
||||||
_start_walking_at(tux, pop->height);
|
_start_walking_at(tux, pop->height);
|
||||||
}
|
}
|
||||||
// ****** WALKER ********
|
// ****** WALKER ********
|
||||||
|
@ -461,7 +449,7 @@ _cb_animator(void *data)
|
||||||
}
|
}
|
||||||
// random custom
|
// random custom
|
||||||
else if (_RAND(CUSTOM_PROB)){
|
else if (_RAND(CUSTOM_PROB)){
|
||||||
_start_custom_at(tux, tux->y+tux->action->h);
|
_start_custom_at(tux, tux->y + tux->action->h);
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
else if (tux->reverse)
|
else if (tux->reverse)
|
||||||
|
@ -481,15 +469,18 @@ _cb_animator(void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tux->y + tux->action->h) < pop->height)
|
if ((tux->y + tux->action->h) < pop->height)
|
||||||
if (!_is_inside_any_win(pop, (int)tux->x+(tux->action->w/2) , (int)tux->y+tux->action->h+1, RETURN_NONE_VALUE))
|
if (!_is_inside_any_win(pop, (int)tux->x + (tux->action->w / 2) ,
|
||||||
_start_falling_at(tux, (int)tux->x+(tux->action->w/2));
|
(int)tux->y + tux->action->h + 1,
|
||||||
|
RETURN_NONE_VALUE))
|
||||||
|
_start_falling_at(tux, (int)tux->x + (tux->action->w / 2));
|
||||||
}
|
}
|
||||||
// right
|
// right
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tux->x += ((double)tux->action->speed * ecore_animator_frametime_get());
|
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, RETURN_LEFT_VALUE)) ||
|
if ((touch = _is_inside_any_win(pop, (int)tux->x + tux->action->w,
|
||||||
(tux->x + tux->action->w) > pop->width)
|
(int)tux->y, RETURN_LEFT_VALUE))
|
||||||
|
|| (tux->x + tux->action->w) > pop->width)
|
||||||
{
|
{
|
||||||
if (_RAND(CLIMBER_PROB))
|
if (_RAND(CLIMBER_PROB))
|
||||||
{
|
{
|
||||||
|
@ -505,8 +496,10 @@ _cb_animator(void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tux->y + tux->action->h) < pop->height)
|
if ((tux->y + tux->action->h) < pop->height)
|
||||||
if (!_is_inside_any_win(pop, (int)tux->x+(tux->action->w/2), (int)tux->y+tux->action->h+1, RETURN_NONE_VALUE))
|
if (!_is_inside_any_win(pop, (int)tux->x + (tux->action->w / 2),
|
||||||
_start_falling_at(tux, (int)tux->x+(tux->action->w/2));
|
(int)tux->y + tux->action->h + 1,
|
||||||
|
RETURN_NONE_VALUE))
|
||||||
|
_start_falling_at(tux, (int)tux->x + (tux->action->w / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ****** FLYER ********
|
// ****** FLYER ********
|
||||||
|
@ -536,14 +529,14 @@ _cb_animator(void *data)
|
||||||
if (tux->reverse)
|
if (tux->reverse)
|
||||||
{
|
{
|
||||||
if (!_is_inside_any_win(pop,
|
if (!_is_inside_any_win(pop,
|
||||||
(int)tux->x-1,
|
(int)tux->x - 1,
|
||||||
(int)tux->y+(tux->action->h/2),
|
(int)tux->y + (tux->action->h / 2),
|
||||||
RETURN_NONE_VALUE))
|
RETURN_NONE_VALUE))
|
||||||
{
|
{
|
||||||
if (tux->x > 0)
|
if (tux->x > 0)
|
||||||
{
|
{
|
||||||
tux->x-=(tux->action->w/2)+1;
|
tux->x -= (tux->action->w / 2) + 1;
|
||||||
_start_walking_at(tux, (int)tux->y+(tux->action->h/2));
|
_start_walking_at(tux, (int)tux->y + (tux->action->h / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,14 +544,14 @@ _cb_animator(void *data)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!_is_inside_any_win(pop,
|
if (!_is_inside_any_win(pop,
|
||||||
(int)tux->x+tux->action->w+1,
|
(int)tux->x + tux->action->w + 1,
|
||||||
(int)tux->y+(tux->action->h/2),
|
(int)tux->y + (tux->action->h / 2),
|
||||||
RETURN_NONE_VALUE))
|
RETURN_NONE_VALUE))
|
||||||
{
|
{
|
||||||
if ((tux->x+tux->action->w) < pop->width)
|
if ((tux->x + tux->action->w) < pop->width)
|
||||||
{
|
{
|
||||||
tux->x+=(tux->action->w/2)+1;
|
tux->x += (tux->action->w / 2) + 1;
|
||||||
_start_walking_at(tux, (int)tux->y+(tux->action->h/2));
|
_start_walking_at(tux, (int)tux->y + (tux->action->h / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,19 +589,14 @@ _is_inside_any_win(Penguins_Population *pop, int x, int y, int ret_value)
|
||||||
{
|
{
|
||||||
case RETURN_NONE_VALUE:
|
case RETURN_NONE_VALUE:
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
|
||||||
case RETURN_RIGHT_VALUE:
|
case RETURN_RIGHT_VALUE:
|
||||||
return ec->x + ec->w;
|
return ec->x + ec->w;
|
||||||
break;
|
|
||||||
case RETURN_BOTTOM_VALUE:
|
case RETURN_BOTTOM_VALUE:
|
||||||
return ec->y + ec->h;
|
return ec->y + ec->h;
|
||||||
break;
|
|
||||||
case RETURN_TOP_VALUE:
|
case RETURN_TOP_VALUE:
|
||||||
return ec->y;
|
return ec->y;
|
||||||
break;
|
|
||||||
case RETURN_LEFT_VALUE:
|
case RETURN_LEFT_VALUE:
|
||||||
return ec->x;
|
return ec->x;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +650,7 @@ _start_walking_at(Penguins_Actor *tux, int at_y)
|
||||||
{
|
{
|
||||||
//printf("PENGUINS: Start walking...at %d\n", at_y);
|
//printf("PENGUINS: Start walking...at %d\n", at_y);
|
||||||
tux->action = eina_hash_find(tux->pop->actions, "Walker");
|
tux->action = eina_hash_find(tux->pop->actions, "Walker");
|
||||||
tux->custom = 0;
|
tux->custom = NULL;
|
||||||
|
|
||||||
tux->y = at_y - tux->action->h;
|
tux->y = at_y - tux->action->h;
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
|
@ -730,7 +718,7 @@ _start_falling_at(Penguins_Actor *tux, int at_x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tux->faller_h = (int)tux->y;
|
tux->faller_h = (int)tux->y;
|
||||||
tux->custom = 0;
|
tux->custom = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -748,7 +736,7 @@ _start_flying_at(Penguins_Actor *tux, int at_y)
|
||||||
static void
|
static void
|
||||||
_start_angel_at(Penguins_Actor *tux, int at_y)
|
_start_angel_at(Penguins_Actor *tux, int at_y)
|
||||||
{
|
{
|
||||||
tux->x = tux->x + (tux->action->w /2);
|
tux->x = tux->x + (tux->action->w / 2);
|
||||||
tux->action = eina_hash_find(tux->pop->actions, "Angel");
|
tux->action = eina_hash_find(tux->pop->actions, "Angel");
|
||||||
if (!tux->action)
|
if (!tux->action)
|
||||||
{
|
{
|
||||||
|
@ -756,10 +744,10 @@ _start_angel_at(Penguins_Actor *tux, int at_y)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tux->x = tux->x - (tux->action->w /2);
|
tux->x = tux->x - (tux->action->w / 2);
|
||||||
tux->y = at_y - 10;
|
tux->y = at_y - 10;
|
||||||
|
|
||||||
tux->custom = 0;
|
tux->custom = NULL;
|
||||||
edje_object_signal_emit(tux->obj, "start_angel", "epenguins");
|
edje_object_signal_emit(tux->obj, "start_angel", "epenguins");
|
||||||
evas_object_move(tux->obj,(int)tux->x,(int)tux->y);
|
evas_object_move(tux->obj,(int)tux->x,(int)tux->y);
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
|
@ -769,8 +757,9 @@ static void
|
||||||
_cb_splatter_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
_cb_splatter_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
{
|
{
|
||||||
Penguins_Actor *tux = data;
|
Penguins_Actor *tux = data;
|
||||||
|
|
||||||
edje_object_signal_callback_del(o,"splatting_done","edje", _cb_splatter_end);
|
edje_object_signal_callback_del(o,"splatting_done","edje", _cb_splatter_end);
|
||||||
_start_angel_at(tux, tux->y+tux->action->h+10);
|
_start_angel_at(tux, tux->y + tux->action->h + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -780,7 +769,6 @@ _start_splatting_at(Penguins_Actor *tux, int at_y)
|
||||||
evas_object_hide(tux->obj);
|
evas_object_hide(tux->obj);
|
||||||
tux->action = eina_hash_find(tux->pop->actions, "Splatter");
|
tux->action = eina_hash_find(tux->pop->actions, "Splatter");
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
|
||||||
tux->y = at_y - tux->action->h;
|
tux->y = at_y - tux->action->h;
|
||||||
if (tux->reverse)
|
if (tux->reverse)
|
||||||
edje_object_signal_emit(tux->obj, "start_splatting_left", "epenguins");
|
edje_object_signal_emit(tux->obj, "start_splatting_left", "epenguins");
|
||||||
|
@ -789,8 +777,7 @@ _start_splatting_at(Penguins_Actor *tux, int at_y)
|
||||||
|
|
||||||
edje_object_signal_callback_add(tux->obj,"splatting_done","edje", _cb_splatter_end, tux);
|
edje_object_signal_callback_add(tux->obj,"splatting_done","edje", _cb_splatter_end, tux);
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||||
evas_object_move(tux->obj,(int)tux->x,(int)tux->y);
|
|
||||||
evas_object_show(tux->obj);
|
evas_object_show(tux->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,6 +785,7 @@ static void
|
||||||
_cb_bomber_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
_cb_bomber_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
{
|
{
|
||||||
Penguins_Actor *tux = data;
|
Penguins_Actor *tux = data;
|
||||||
|
|
||||||
edje_object_signal_callback_del(o,"bombing_done","edje", _cb_bomber_end);
|
edje_object_signal_callback_del(o,"bombing_done","edje", _cb_bomber_end);
|
||||||
_start_angel_at(tux, tux->y);
|
_start_angel_at(tux, tux->y);
|
||||||
}
|
}
|
||||||
|
@ -818,21 +806,21 @@ _start_bombing_at(Penguins_Actor *tux, int at_y)
|
||||||
else
|
else
|
||||||
edje_object_signal_emit(tux->obj, "start_bombing_right", "epenguins");
|
edje_object_signal_emit(tux->obj, "start_bombing_right", "epenguins");
|
||||||
|
|
||||||
tux->x = tux->x + (tux->action->w /2);
|
tux->x = tux->x + (tux->action->w / 2);
|
||||||
tux->action = eina_hash_find(tux->pop->actions, "Bomber");
|
tux->action = eina_hash_find(tux->pop->actions, "Bomber");
|
||||||
tux->x = tux->x - (tux->action->w /2);
|
tux->x = tux->x - (tux->action->w / 2);
|
||||||
tux->y = at_y - tux->action->h;
|
tux->y = at_y - tux->action->h;
|
||||||
|
|
||||||
edje_object_signal_callback_add(tux->obj,"bombing_done","edje", _cb_bomber_end, tux);
|
edje_object_signal_callback_add(tux->obj,"bombing_done","edje", _cb_bomber_end, tux);
|
||||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
|
||||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||||
evas_object_move(tux->obj,(int)tux->x,(int)tux->y);
|
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)
|
||||||
{
|
{
|
||||||
Penguins_Actor* tux = data;
|
Penguins_Actor* tux = data;
|
||||||
|
|
||||||
//printf("PENGUINS: Custom action end.\n");
|
//printf("PENGUINS: Custom action end.\n");
|
||||||
if (!tux->custom)
|
if (!tux->custom)
|
||||||
return;
|
return;
|
||||||
|
@ -848,7 +836,7 @@ _cb_custom_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
edje_object_signal_callback_del(o,"custom_done","edje", _cb_custom_end);
|
edje_object_signal_callback_del(o,"custom_done","edje", _cb_custom_end);
|
||||||
_start_walking_at(tux, tux->y+tux->custom->h);
|
_start_walking_at(tux, tux->y + tux->custom->h);
|
||||||
tux->custom = NULL;
|
tux->custom = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,17 +850,14 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ran = random() % (tux->pop->custom_num);
|
ran = random() % (tux->pop->custom_num);
|
||||||
//ran=2; //!!!!
|
|
||||||
//printf("START CUSTOM NUM %d RAN %d\n",tux->pop->custom_num, ran);
|
//printf("START CUSTOM NUM %d RAN %d\n",tux->pop->custom_num, ran);
|
||||||
|
|
||||||
tux->custom = eina_list_nth(tux->pop->customs, ran);
|
tux->custom = eina_list_nth(tux->pop->customs, ran);
|
||||||
if (!tux->custom)
|
if (!tux->custom) return;
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
evas_object_resize(tux->obj, tux->custom->w, tux->custom->h);
|
evas_object_resize(tux->obj, tux->custom->w, tux->custom->h);
|
||||||
tux->y = at_y - tux->custom->h;
|
tux->y = at_y - tux->custom->h;
|
||||||
|
|
||||||
if ( tux->custom->r_min == tux->custom->r_max)
|
if ( tux->custom->r_min == tux->custom->r_max)
|
||||||
tux->r_count = tux->custom->r_min;
|
tux->r_count = tux->custom->r_min;
|
||||||
else
|
else
|
||||||
|
@ -890,4 +875,3 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
|
||||||
edje_object_signal_callback_add(tux->obj,"custom_done","edje", _cb_custom_end, tux);
|
edje_object_signal_callback_add(tux->obj,"custom_done","edje", _cb_custom_end, tux);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue