+
+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;
+}