summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-17 21:54:00 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-17 21:54:00 +0000
commit462243c4dfb86b7ed67a0df6ddc19552cf3d2ff9 (patch)
tree1770841ddfee6b8c30009e256dad5b6eefa66fbf
parentdd565ea6b9e7d1b1cbf8ff7f61175303c5d05fca (diff)
drift the flakes a little
-rw-r--r--src/e_mod_main.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index b69b884..4c525fd 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -289,22 +289,40 @@ _snow_cb_animator(void *data)
289{ 289{
290 Snow *snow; 290 Snow *snow;
291 Eina_List *next; 291 Eina_List *next;
292 Evas_Coord ww;
292 double d; 293 double d;
293 294
294 snow = data; 295 snow = data;
296 evas_output_viewport_get(snow->canvas, NULL, NULL, &ww, NULL);
297
295 next = snow->flakes; 298 next = snow->flakes;
296 while (next) 299 while (next)
297 { 300 {
298 Snow_Flake *flake; 301 Snow_Flake *flake;
299 Evas_Coord x, y; 302 Evas_Coord x, y;
303 int drift;
300 304
301 flake = next->data; 305 flake = next->data;
302 d = ecore_time_get() - flake->start_time; 306 d = ecore_time_get() - flake->start_time;
303 y = 30 * d * flake->speed; 307 y = 30 * d * flake->speed;
308 switch (rand() % 22)
309 {
310 case 19:
311 drift = -1;
312 break;
313 case 20:
314 case 21:
315 drift = 1;
316 break;
317 default:
318 drift = 0;
319 }
304 evas_object_geometry_get(flake->flake, &x, NULL, NULL, NULL); 320 evas_object_geometry_get(flake->flake, &x, NULL, NULL, NULL);
305 if (y > snow->height) 321 if (y > snow->height)
306 flake->start_time = ecore_time_get() + (double)(random() % 100) / (double)100; 322 flake->start_time = ecore_time_get() + (double)(random() % 100) / (double)100;
307 evas_object_move(flake->flake, x, y); 323 if (x + drift >= ww)
324 x = 0;
325 evas_object_move(flake->flake, x + drift, y);
308 326
309 next = eina_list_next(next); 327 next = eina_list_next(next);
310 } 328 }