done moving bone without accel fifteen1
authortanya <tanya@moshkanov.oblgaz>
Tue, 31 Aug 2010 17:25:36 +0000 (20:25 +0300)
committertanya <tanya@moshkanov.oblgaz>
Tue, 31 Aug 2010 17:25:36 +0000 (20:25 +0300)
16 files changed:
applet/data/theme/Fifteen/1.png [new file with mode: 0644]
applet/data/theme/Fifteen/10.png [new file with mode: 0644]
applet/data/theme/Fifteen/11.png [new file with mode: 0644]
applet/data/theme/Fifteen/12.png [new file with mode: 0644]
applet/data/theme/Fifteen/13.png [new file with mode: 0644]
applet/data/theme/Fifteen/14.png [new file with mode: 0644]
applet/data/theme/Fifteen/15.png [new file with mode: 0644]
applet/data/theme/Fifteen/2.png [new file with mode: 0644]
applet/data/theme/Fifteen/3.png [new file with mode: 0644]
applet/data/theme/Fifteen/4.png [new file with mode: 0644]
applet/data/theme/Fifteen/5.png [new file with mode: 0644]
applet/data/theme/Fifteen/6.png [new file with mode: 0644]
applet/data/theme/Fifteen/7.png [new file with mode: 0644]
applet/data/theme/Fifteen/8.png [new file with mode: 0644]
applet/data/theme/Fifteen/9.png [new file with mode: 0644]
applet/src/fifteen.c

diff --git a/applet/data/theme/Fifteen/1.png b/applet/data/theme/Fifteen/1.png
new file mode 100644 (file)
index 0000000..32d6dee
Binary files /dev/null and b/applet/data/theme/Fifteen/1.png differ
diff --git a/applet/data/theme/Fifteen/10.png b/applet/data/theme/Fifteen/10.png
new file mode 100644 (file)
index 0000000..8df8731
Binary files /dev/null and b/applet/data/theme/Fifteen/10.png differ
diff --git a/applet/data/theme/Fifteen/11.png b/applet/data/theme/Fifteen/11.png
new file mode 100644 (file)
index 0000000..03b39e4
Binary files /dev/null and b/applet/data/theme/Fifteen/11.png differ
diff --git a/applet/data/theme/Fifteen/12.png b/applet/data/theme/Fifteen/12.png
new file mode 100644 (file)
index 0000000..bf582fb
Binary files /dev/null and b/applet/data/theme/Fifteen/12.png differ
diff --git a/applet/data/theme/Fifteen/13.png b/applet/data/theme/Fifteen/13.png
new file mode 100644 (file)
index 0000000..a609884
Binary files /dev/null and b/applet/data/theme/Fifteen/13.png differ
diff --git a/applet/data/theme/Fifteen/14.png b/applet/data/theme/Fifteen/14.png
new file mode 100644 (file)
index 0000000..8643809
Binary files /dev/null and b/applet/data/theme/Fifteen/14.png differ
diff --git a/applet/data/theme/Fifteen/15.png b/applet/data/theme/Fifteen/15.png
new file mode 100644 (file)
index 0000000..3a41a85
Binary files /dev/null and b/applet/data/theme/Fifteen/15.png differ
diff --git a/applet/data/theme/Fifteen/2.png b/applet/data/theme/Fifteen/2.png
new file mode 100644 (file)
index 0000000..98ef6cb
Binary files /dev/null and b/applet/data/theme/Fifteen/2.png differ
diff --git a/applet/data/theme/Fifteen/3.png b/applet/data/theme/Fifteen/3.png
new file mode 100644 (file)
index 0000000..f6d8a93
Binary files /dev/null and b/applet/data/theme/Fifteen/3.png differ
diff --git a/applet/data/theme/Fifteen/4.png b/applet/data/theme/Fifteen/4.png
new file mode 100644 (file)
index 0000000..1ba9e2b
Binary files /dev/null and b/applet/data/theme/Fifteen/4.png differ
diff --git a/applet/data/theme/Fifteen/5.png b/applet/data/theme/Fifteen/5.png
new file mode 100644 (file)
index 0000000..19e0da5
Binary files /dev/null and b/applet/data/theme/Fifteen/5.png differ
diff --git a/applet/data/theme/Fifteen/6.png b/applet/data/theme/Fifteen/6.png
new file mode 100644 (file)
index 0000000..9749f61
Binary files /dev/null and b/applet/data/theme/Fifteen/6.png differ
diff --git a/applet/data/theme/Fifteen/7.png b/applet/data/theme/Fifteen/7.png
new file mode 100644 (file)
index 0000000..bee766e
Binary files /dev/null and b/applet/data/theme/Fifteen/7.png differ
diff --git a/applet/data/theme/Fifteen/8.png b/applet/data/theme/Fifteen/8.png
new file mode 100644 (file)
index 0000000..adfe4a1
Binary files /dev/null and b/applet/data/theme/Fifteen/8.png differ
diff --git a/applet/data/theme/Fifteen/9.png b/applet/data/theme/Fifteen/9.png
new file mode 100644 (file)
index 0000000..b0657bf
Binary files /dev/null and b/applet/data/theme/Fifteen/9.png differ
index c71c8fe..24347d4 100644 (file)
@@ -1,12 +1,74 @@
 #include <hildon/hildon.h>
+#include <time.h>
 #include "livewp-common.h"
 #include "livewp-actor.h"
+
+enum {
+    UP = 0,
+    RIGHT = 1,
+    DOWN = 2,
+    LEFT = 3
+};
+
+gint pg[16];
+Actor *actors[15];
+gint empty;
+
+void init_pg(gint *pg)
+{
+    srand(time(NULL));
+    gint i, j, t;
+    for (i=0; i<16; i++){
+        pg[i] = i;
+    }
+    for (i=0; i<15; i++){
+        j = rand()%15;
+        t = pg[i];
+        pg[i] = pg[j];
+        pg[j] = t;
+    }
+}
+
+void move(gint direction, AWallpaperPlugin *desktop_plugin)
+{
+    gint bone;
+    Actor *actor;
+    switch (direction) {
+        case UP:
+            bone = empty + 4;
+            if (bone > 15) return;
+            break;
+        case RIGHT:
+            bone = empty - 1;
+            if (empty % 4 == 0) return;
+            break;
+        case DOWN:
+            bone = empty - 4;
+            if (bone < 0) return;
+            break;
+        case LEFT:
+            bone = empty + 1;
+            if (bone % 4) return;
+    }
+    fprintf(stderr, "from %d to %d x=%d y=%d\n", bone, empty, (empty%4)*200, (empty/4)*120);
+    actor = actors[pg[bone]];
+    set_actor_position(actor, (empty%4)*200, (empty/4)*120, actor->z, desktop_plugin);
+    pg[empty] = pg[bone];
+    pg[bone] = 15;
+    empty = bone;
+}
+gboolean make_move(AWallpaperPlugin *desktop_plugin)
+{
+    move(RIGHT, desktop_plugin);
+    return TRUE;
+}
 int main( int   argc, char *argv[] )
 {
     GtkWidget *window;
     AWallpaperPlugin *desktop_plugin = g_new0 (AWallpaperPlugin, 1);
     Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1);
     Actor *actor;
+    gint i;
 
     hildon_gtk_init (&argc, &argv);
     g_set_application_name ("Simplest example");
@@ -14,13 +76,21 @@ int main( int   argc, char *argv[] )
     g_signal_connect (G_OBJECT (window), "delete_event",
                         G_CALLBACK (gtk_main_quit), NULL);
     priv->window = window;
-    priv->theme = g_strdup("Modern"); 
+    priv->theme = g_strdup("Fifteen"); 
+    priv->xapplet = 0;
+    priv->yapplet = 0;
     desktop_plugin->priv = priv;
-    actor = init_object(desktop_plugin, "sun", "sun.png", 
-                      10, 10, 6, 88, 88, 
+    init_pg(pg);
+    empty = 15;
+    for (i=0; i<15; i++){
+        actor = init_object(desktop_plugin, "bone", g_strdup_printf("%d.png", pg[i]+1), 
+                      (i%4)*200, (i/4)*120, 2, 200, 120, 
                       TRUE, TRUE, 100, 255, 
                       NULL, NULL, NULL);
+        actors[pg[i]] = actor;
+    }
     gtk_widget_show  (window);
+    g_timeout_add(4000, make_move, desktop_plugin);
     gtk_main ();
     return 0;
 }