From: tanya Date: Thu, 29 Jul 2010 12:39:00 +0000 (+0300) Subject: done tapes moved with accelerometer X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=29326c7fddedc0a1bb69698e18a5cef189338b43;p=livewp done tapes moved with accelerometer --- diff --git a/applet/src/livewp-actor.c b/applet/src/livewp-actor.c index 6286b20..07098a4 100644 --- a/applet/src/livewp-actor.c +++ b/applet/src/livewp-actor.c @@ -699,25 +699,47 @@ change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin) } //fprintf(stderr, "change obj %i %i %i angle rad=%f, deg=%f\n", ax, ay, az, atan2(ax, -ay), atan2(ax, -ay)*180/M_PI); - angle = atan2(ay, ax); + int ang = (int)floor(atan2(ay, ax)*180/M_PI); + if (ang < 0) ang = 360+ang; if (!desktop_plugin->priv->rich_animation) return; - for (i=0; i<24; i++){ + for (i=0; i<16; i++){ a = g_ptr_array_index(actor->child, i); - //x = a->x - cos(angle*M_PI/180)*a->z; - //y = a->y - sin(angle*M_PI/180)*a->z; - x = a->x - cos(angle)*a->z; - y = a->y - sin(angle)*a->z; - if (x <= -a->width) - x = 800; - if (y <= -a->width) - y = 480; - if (x > 800+a->width) + if (a->scale == 100) a->scale = ang; + if (abs(a->scale - ang) > 10){ + if (a->scale > ang) + if ((a->scale - ang) < (ang + (360-a->scale))) a->scale--; + else a->scale++; + if (a->scale < ang) + if (ang - a->scale < (a->scale+(360-ang))) a->scale++; + else a->scale--; + if (a->scale > 360) a->scale = 0; + if (a->scale < 0) a->scale = 360; + } + + x = round(a->x - (float)cos(a->scale*M_PI/180)*a->z); + y = round(a->y - (float)sin(a->scale*M_PI/180)*a->z); + //x = a->x - cos(angle)*a->z; + //y = a->y - sin(angle)*a->z; + if ((a->scale > 270 || a->scale < 90) && x < -a->width*cos(a->scale*M_PI/180)){ + x = 800; + y = fast_rnd(480); + } + if ((a->scale > 90 && a->scale < 270) && x > 800 - a->width*cos(a->scale*M_PI/180)){ x = 0; - if (y > 480+a->width) + y = fast_rnd(480); + } + if (a->scale > 0 && a->scale < 180 && y < -a->width*sin(a->scale*M_PI/180)){ + y = 480; + x = fast_rnd(800); + } + if (a->scale < 360 && a->scale > 180 && y > 480 - a->width*sin(a->scale*M_PI/180)){ y = 0; - set_actor_rotation(a, HILDON_AA_Z_AXIS, angle*180/M_PI, 0, 0, 0); + x = fast_rnd(800); + } + //if (i ==0) fprintf(stderr, "x=%d y=%d ang=%d speed=%d\n", x, y, a->scale, a->z); + set_actor_rotation(a, HILDON_AA_Z_AXIS, a->scale, 0, 0, 0); set_actor_position(a, x, y, a->z, desktop_plugin); a->x = x; a->y = y; diff --git a/applet/src/livewp-scene.c b/applet/src/livewp-scene.c index c658a60..4851db8 100644 --- a/applet/src/livewp-scene.c +++ b/applet/src/livewp-scene.c @@ -61,6 +61,7 @@ init_scene_Accel(AWallpaperPlugin *desktop_plugin) gint now = time(NULL); gchar *str; gint sizes[4] = {170, 229, 130, 150}, + sizes1[4] = {57, 76, 43, 50}, heights[4] = {0, 100, 200, 300}, n, i, j; @@ -70,25 +71,25 @@ init_scene_Accel(AWallpaperPlugin *desktop_plugin) desktop_plugin->priv->scene = scene; actor = init_object(desktop_plugin, "background", "bg.png", - 0, 0, 5, 800, 480, + 0, 0, 0, 800, 480, TRUE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); - child = g_ptr_array_sized_new(24); + child = g_ptr_array_sized_new(16); - for (j= 0; j<2; j++){ + for (j= 0; j<4; j++){ for (n=0; n<4; n++){ - for (i=0; i<3; i++){ - str = g_strdup_printf("tape%i_%i.png", n+1, i); + //for (i=0; i<3; i++){ + str = g_strdup_printf("tape%i.png", n+1); actor = init_object(desktop_plugin, "tape", str, - fast_rnd(700), fast_rnd(430), 1+fast_rnd(10), 800, sizes[n], + fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n], TRUE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); g_ptr_array_add(child, actor); g_free(str); - } + //} } } actor = init_object(desktop_plugin, "tape", "",