summaryrefslogtreecommitdiff
path: root/super_donators
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-11-26 10:44:16 -0500
committerirungentoo <irungentoo@gmail.com>2015-11-26 10:44:16 -0500
commit516b6ab46c6735db673ea68f4f117c0d53d755f1 (patch)
treeb61bfa5b09019c9c4abba940fcbce62e140236cd /super_donators
parent73b2144edcfd1ca617e9054479b66ab0c0361a14 (diff)
Forgot to commit these.
Diffstat (limited to 'super_donators')
-rw-r--r--super_donators/grencez_tok5.c41
-rwxr-xr-xsuper_donators/sir@cmpwn.com21
2 files changed, 62 insertions, 0 deletions
diff --git a/super_donators/grencez_tok5.c b/super_donators/grencez_tok5.c
new file mode 100644
index 00000000..5c5be83c
--- /dev/null
+++ b/super_donators/grencez_tok5.c
@@ -0,0 +1,41 @@
1/* Though it may look bleak at times,
2 * this ring will stabilize to have one token,
3 * and Tox will be the one true chat protocol!
4 * -- Alex P. Klinkhamer (grencez)
5 */
6#include <unistd.h>
7#include <stdlib.h>
8#include <stdio.h>
9int main(int i, char** msg)
10{
11 int j, fd[4], xpd, xid;
12 if (--i<1) return 1;
13 srand(getpid());
14 pipe(fd);
15 while (xid=rand()%5, --i>0) {
16 pipe(&fd[2]);
17 j = (0==fork() ? 0 : 1);
18 close(fd[j]);
19 fd[j] = fd[j+2];
20 close(fd[3-j]);
21 if (j==0) break;
22 }
23#define SendSc() write(fd[1], &xid, sizeof(xid))
24#define RecvPd() read(fd[0], &xpd, sizeof(xpd))
25#define A(g,v) if (g) {xid=v; puts(msg[i+1]); fflush(stdout); SendSc();}
26 SendSc();
27 while (RecvPd(), 1) {
28 sleep(1);
29 if (i==0) {
30 A( xpd==0 && xid==0 , 1 );
31 A( xpd==1 && xid<=1 , 2 );
32 A( xpd> 1 && xid> 1 , 0 );
33 continue;
34 }
35 A( xpd==0 && xid> 1 , xid/4 );
36 A( xpd==1 && xid!=1 , 1 );
37 A( xpd==2 && xid<=1 , 2+xid );
38 A( xpd>=3 && xid<=1 , 4 );
39 }
40 return 0;
41}
diff --git a/super_donators/sir@cmpwn.com b/super_donators/sir@cmpwn.com
new file mode 100755
index 00000000..cfa989b0
--- /dev/null
+++ b/super_donators/sir@cmpwn.com
@@ -0,0 +1,21 @@
1#!/bin/bash
2# Run ./sir@cmpwn.com
3# Arrow keys or wasd to move
4
5c=`tput cols`;L=`tput lines`
6let x=$c/2;let y=$L/2;d=0;le=3;t="$y;$x";i=0;j=0;S=0
7A(){ let i=($RANDOM%$c);let j=($RANDOM%$L);};A
8B(){ printf $*;};C(){ B "\x1B[$1";};D(){ C "$1H";}
9F(){ D "0;0";C 2J;C "?25h";printf "GAME OVER\nSCORE: $S\n";exit;};trap F INT
10C ?25l;C 2J;da(){ D "$j;$i";echo "$1";}
11G() { for n in $t; do D "$n";echo "$1";done;}
12mt(){ t=`echo "$t"|cut -d' ' -f2-`;}
13sc(){ D "0;0";echo "Score: $S"; }
14gt() { t+=" $y;$x";};ct() { for n in $t; do [ "$y;$x" == "$n" ]&&F;done;}
15M() { case $d in 0)let y--;;1)let x--;;2)let y++;;3)let x++;;esac
16let x%=$c;let y%=$L;ct;[ "$y$x" == "$j$i" ]&&{ let le++;A;let S++;}
17l=`tr -dc ' '<<<"$t"|wc -c`;gt;[ $l -gt $le ]&&mt;}
18ky() { k=$1;read -sN1 -t 0.01 k1;read -sN1 -t 0.01 k2;read -sN1 -t 0.01 k3
19k+=${k1}${k2}${k3};case $k in w|$'\e[A'|$'\e0A')d=0;;a|$'\e[D'|$'\e0D')d=1;;
20s|$'\e[B'|$'\e0B')d=2;;d|$'\e[C'|$'\e0C')d=3;;esac;}
21while :;do da ' ';G ' ';M;da "@";G "#";sc;read -s -n 1 -t 0.1 k && ky "$k";done