summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-04-09 14:25:12 +0200
committerAlexander Larsson <alexl@redhat.com>2010-04-09 14:25:12 +0200
commit0a4034e752b77c0784206fb3e570cbf73b7029a9 (patch)
tree9c77060b233bfd0b8a926d04d45b5b9f27186786
parent7b57a601227811a94dd14abfa3d09bd6d5717d43 (diff)
Make ball bounceHEADmaster
-rw-r--r--daemon.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/daemon.c b/daemon.c
index 885c74a..45c7380 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,11 +1,12 @@
/* Build with
- gcc `pkg-config --cflags --libs gio-2.0` daemon.c -o daemon
+ gcc `pkg-config --cflags --libs gio-2.0` -lm daemon.c -o daemon
*/
#include <gio/gio.h>
#include <string.h>
#include <stdint.h>
#include <arpa/inet.h>
+#include <math.h>
/************************************************************************
* conversion of raw image data to uncompressed png data: uris *
@@ -743,6 +744,7 @@ demo (GOutputStream *out)
GOutputStream *cout;
char *header;
int i;
+ int x, y, dx;
int ball, save;
header =
@@ -776,16 +778,26 @@ demo (GOutputStream *out)
send_text(cout, "welcome to ajax broadway", 403, 403);
i = 0;
+ x = 0; dx = 9;
while (1)
{
send_select_surface(cout, 0);
- send_rgb (cout, 0xff0000 + i * 32);
- send_rect (cout, i*10, i*10, 15, 15);
- send_rgba (cout, 0x80ff0000 + i * 32);
- send_rect (cout, i*10 + 50, i*10, 15, 15);
- send_blend_alpha (cout, ball, 0, 0, 50, 50,
- 200 + i * 20, 200 - i * 30, 70);
+ send_rgb (cout, 0x00000);
+ send_rect (cout, x, y, ball_w, ball_h);
+
+ x += dx;
+ if (x > 700) {
+ x = 700 - (x-700);
+ dx = -dx;
+ }
+ if (x < 0) {
+ x = -x;
+ dx = -dx;
+ }
+ y = 300 - fabs(sin(i * M_PI * 2 / 60)) * 300;
+ send_blend (cout, ball, 0, 0, ball_w, ball_h,
+ x, y);
i ++;