?

Log in

Random Acts of Boredom - The Desian Universe
Links Home / GitHub January 2017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
 
 
 
deskitty
deskitty
Des
Wed, Feb. 16th, 2005 10:36 am
Random Acts of Boredom

I logged into my server today, and it gave me the following little gem:

You have a strong appeal for members of your own sex.

condor@deneb ~>


::sigh:: If only that were true ... ::rolls eyes::

>>>

Dr. Nico told me about this amusing little program called xroach. It makes roaches run around on your desktop (if you have UNIX) and hide under your windows. It amused me, so I just spent the past half-hour hacking on it to get the roaches to move at a reasonable speed.

Here's the patch:

diff -Nru xroach-4.0/xroach.c xroach-4.0-des1/xroach.c
--- xroach-4.0/xroach.c 1991-06-06 05:12:07.000000000 -0700
+++ xroach-4.0-des1/xroach.c    2005-02-16 10:30:12.000000000 -0800
@@ -32,6 +32,8 @@
 #include <malloc.h>
 #include <signal.h>

+#include <time.h>
+
 #if __STDC__
 #include <stdlib.h>
 #else
@@ -85,7 +87,8 @@
 Roach *roaches;
 int maxRoaches = 10;
 int curRoaches = 0;
-float roachSpeed = 20.0;
+float roachSpeed = 20;
+float roachStep = 20.0;

 Region rootVisible = NULL;

@@ -133,6 +136,9 @@
    else if (strcmp(arg, "-speed") == 0) {
        roachSpeed = strtod(av[++ax], (char **)NULL);
    }
+    else if (strcmp(arg, "-step") == 0) {
+        roachStep = strtod(av[++ax], (char **)NULL);
+    }
    else if (strcmp(arg, "-roaches") == 0) {
        maxRoaches = strtol(av[++ax], (char **)NULL, 0);
    }
@@ -231,6 +237,10 @@
        XNextEvent(display, &ev);
    }
    else {
+        struct timespec ts;
+        ts.tv_sec = 0;
+        ts.tv_nsec = (long)(1000000000/roachSpeed);
+        nanosleep(&ts, NULL);
        if (needCalc) {
        needCalc = CalcRootVisible();
        }
@@ -303,6 +313,7 @@
     USEPRT("       -rc      roachcolor\n");
     USEPRT("       -roaches numroaches\n");
     USEPRT("       -speed   roachspeed\n");
+    USEPRT("       -step    roachstep\n");
     USEPRT("       -squish\n");
     USEPRT("       -rgc     roachgutscolor\n");

@@ -494,8 +505,8 @@
     int ii;

     roach = &roaches[rx];
-    newX = roach->x + (roachSpeed * roach->rp->cosine);
-    newY = roach->y - (roachSpeed * roach->rp->sine);
+    newX = roach->x + (roachStep * roach->rp->cosine);
+    newY = roach->y - (roachStep * roach->rp->sine);

     if (RoachInRect(roach, (int)newX, (int)newY,
                0, 0, display_width, display_height)) {




So, yeah ... maybe I should actually work on that compilers homework that's due later today ...

-- Des

Current Mood: bored bored

CommentReplyShare