moving tram depend on time
authorTanya <tanya@bookdmitri.oblgaz>
Sun, 4 Apr 2010 18:37:19 +0000 (21:37 +0300)
committerTanya <tanya@bookdmitri.oblgaz>
Sun, 4 Apr 2010 18:37:19 +0000 (21:37 +0300)
applet/src/livewp-home-widget.c
applet/src/livewp-rules.h

index ebf002b..ca8f392 100644 (file)
@@ -288,27 +288,21 @@ void change_background(GtkWidget * actor, gpointer data)
     }
 }
 
-static void path_tram(GtkWidget * actor, gint* t)
+static void path_tram(GtkWidget * actor, gint t)
 {
     gint x0 = -300, y0 = 191, scale0 = 100, t0 = 0,
          x1 = 800, y1 = 119, scale1 = 130, t1 = 100, 
          x, y, scale;
-    x = 12 * *t - 300;
-    y = -0.72 * *t + 191;
-    scale = 0.3 * *t + 100;
-    if (x >= x1){
-        x = x0;
-        y = y0;
-        scale = scale0;
-        *t = 0;
-    }
-    fprintf(stderr, "path tram:  t=%i, x=%i, y=%i, scale=%i\n", *t, x, y, scale);
+    x = 12 * t - 300;
+    y = -0.72 * t + 191;
+    scale = 0.3 * t + 100;
+    //fprintf(stderr, "path tram:  t=%i, x=%i, y=%i, scale=%i\n", t, x, y, scale);
     actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
     hildon_animation_actor_set_scale(actor, (double)scale/100, (double)scale/100);
 }
 static gint get_time(gint t)
 {
-    return t*1.2;
+    return t*1.1;
     
 }
 
@@ -321,6 +315,7 @@ init_scene(GtkWidget *window)
   double alt, azm;
   gint x, y;
   GSList * list = NULL;
+  gchar str[256];
 
   scene.window = window;
   scene.daytime = get_daytime();
@@ -334,15 +329,20 @@ init_scene(GtkWidget *window)
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
   //ma1->multiactor_init("sun", g_slist_append(list, G_OBJECT(actor)));
 
-  actor = init_object("sky", "sky.png", 0, 0, 5, 800, 480, 1, 100, 255, NULL);
+  snprintf(str, 255, "sky%i.png", scene.daytime);
+  actor = init_object("sky", str, 0, 0, 5, 800, 480, 1, 100, 255, NULL);
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
 
-  actor = init_object("town", "town.png", 0, 480-374, 10, 800, 374, 1, 100, 255, NULL);
+  snprintf(str, 255, "town%i.png", scene.daytime);
+  actor = init_object("town", str, 0, 480-374, 10, 800, 374, 1, 100, 255, NULL);
   scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
   
-  actor = init_object("border", "border.png", 0, 480-79, 30, 800, 79, 1, 100, 255, NULL);
+  snprintf(str, 255, "border%i.png", scene.daytime);
+  actor = init_object("border", str, 0, 480-79, 30, 800, 79, 1, 100, 255, NULL);
   scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
   
+  //if (scene.daytime == TIME_DAY) snprintf(str, 255, "tram.png");
+  //else snprintf(str, 255, "tram_dark.png");
   actor = init_object("tram", "tram.png", -300, 191, 25, 350, 240, 1, 100, 255, NULL);
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
  }
@@ -516,8 +516,10 @@ plugin_on_timeout (AWallpaperPlugin *desktop_plugin)
       pfunc = g_object_get_data(G_OBJECT(tmp->data), "func");
       name = g_object_get_data(G_OBJECT(tmp->data), "name");
       if (name == "tram"){
-          path_tram(tmp->data, &ttt);
+          path_tram(tmp->data, ttt);
+          //ttt = get_time(ttt+1);
           ttt = get_time(ttt+1);
+          if (ttt >= 100) ttt = 0;
         }else
       if (pfunc){
           (*pfunc)(tmp->data, NULL);
@@ -595,7 +597,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
   gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
   init_applet_position();
   init_scene(desktop_plugin);
-  priv->timer = g_timeout_add(1000, plugin_on_timeout, desktop_plugin);
+  priv->timer = g_timeout_add(500, plugin_on_timeout, desktop_plugin);
 }
 
 static void
index 3cba194..9def725 100644 (file)
@@ -28,9 +28,9 @@
 #include "livewp-astro.h"
 /*******************************************************************************/
 #define TIME_DAY        0
-#define TIME_NIGHT      1
-#define TIME_SUNRISE    2
-#define TIME_SUNSET     3
+#define TIME_NIGHT      3 
+#define TIME_SUNRISE    1
+#define TIME_SUNSET     2
 
 #define MOON_NONE               0
 #define MOON_GROWS              1