diff options
author | epoch <epoch@hacking.allowed.org> | 2019-02-06 00:53:08 -0600 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2019-02-06 00:53:08 -0600 |
commit | bf16b7b8593d4013adbd03838af5a2fb3bce34ee (patch) | |
tree | 25944f4d4907a075e513f03b7e37a99f4c813752 /share/hackvr/examples/tictactoe | |
parent | 73c246a797fc6c1bac132b4eb242e1c90540e2d4 (diff) | |
download | hackvr-bf16b7b8593d4013adbd03838af5a2fb3bce34ee.tar.gz hackvr-bf16b7b8593d4013adbd03838af5a2fb3bce34ee.zip |
I forgot to add the examples dir somehow. they're back. tictactoe works again too.
Diffstat (limited to 'share/hackvr/examples/tictactoe')
-rw-r--r-- | share/hackvr/examples/tictactoe/board | 13 | ||||
-rw-r--r-- | share/hackvr/examples/tictactoe/board_orig | 13 | ||||
-rw-r--r-- | share/hackvr/examples/tictactoe/camera.pos | 5 | ||||
-rwxr-xr-x | share/hackvr/examples/tictactoe/game.sh | 30 | ||||
-rwxr-xr-x | share/hackvr/examples/tictactoe/listen.sh | 19 | ||||
-rw-r--r-- | share/hackvr/examples/tictactoe/marker0 | 2 | ||||
-rw-r--r-- | share/hackvr/examples/tictactoe/marker1 | 1 | ||||
-rwxr-xr-x | share/hackvr/examples/tictactoe/run | 6 |
8 files changed, 89 insertions, 0 deletions
diff --git a/share/hackvr/examples/tictactoe/board b/share/hackvr/examples/tictactoe/board new file mode 100644 index 0000000..607ebf3 --- /dev/null +++ b/share/hackvr/examples/tictactoe/board @@ -0,0 +1,13 @@ +_reset addshape 2 3 -4 6 4 -5 6 4 -4 5 4 + +topleft addshape 2 4 -3 13 4 -1 13 4 -1 11 4 -3 11 4 +topcenter addshape 2 4 -1 13 4 1 13 4 1 11 4 -1 11 4 +topright addshape 2 4 1 13 4 3 13 4 3 11 4 1 11 4 + +middleleft addshape 2 4 -3 11 4 -1 11 4 -1 9 4 -3 9 4 +middlecenter addshape 2 4 -1 11 4 1 11 4 1 9 4 -1 9 4 +middleright addshape 2 4 1 11 4 3 11 4 3 9 4 1 9 4 + +bottomleft addshape 2 4 -3 9 4 -1 9 4 -1 7 4 -3 7 4 +bottomcenter addshape 2 4 -1 9 4 1 9 4 1 7 4 -1 7 4 +bottomright addshape 2 4 1 9 4 3 9 4 3 7 4 1 7 4 diff --git a/share/hackvr/examples/tictactoe/board_orig b/share/hackvr/examples/tictactoe/board_orig new file mode 100644 index 0000000..2d8a0e5 --- /dev/null +++ b/share/hackvr/examples/tictactoe/board_orig @@ -0,0 +1,13 @@ +_reset addshape 2 3 -4 -4 4 -5 -4 4 -4 -5 4 + +topleft addshape 2 4 -3 3 4 -1 3 4 -1 1 4 -3 1 4 +topcenter addshape 2 4 -1 3 4 1 3 4 1 1 4 -1 1 4 +topright addshape 2 4 1 3 4 3 3 4 3 1 4 1 1 4 + +middleleft addshape 2 4 -3 1 4 -1 1 4 -1 -1 4 -3 -1 4 +middlecenter addshape 2 4 -1 1 4 1 1 4 1 -1 4 -1 -1 4 +middleright addshape 2 4 1 1 4 3 1 4 3 -1 4 1 -1 4 + +bottomleft addshape 2 4 -3 -1 4 -1 -1 4 -1 -3 4 -3 -3 4 +bottomcenter addshape 2 4 -1 -1 4 1 -1 4 1 -3 4 -1 -3 4 +bottomright addshape 2 4 1 -1 4 3 -1 4 3 -3 4 1 -3 4 diff --git a/share/hackvr/examples/tictactoe/camera.pos b/share/hackvr/examples/tictactoe/camera.pos new file mode 100644 index 0000000..ef8e9da --- /dev/null +++ b/share/hackvr/examples/tictactoe/camera.pos @@ -0,0 +1,5 @@ +junk set global.zoom 45 +junk set camera.p.z -6 +junk set camera.p.y -1 +junk set camera.p.x 0 + diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh new file mode 100755 index 0000000..63776f4 --- /dev/null +++ b/share/hackvr/examples/tictactoe/game.sh @@ -0,0 +1,30 @@ +#!/bin/bash +turn=$( expr $RANDOM % 2) +cat camera.pos | sed 's/^junk/$USER/g' +echo "go. player: $turn" >&2 +stdbuf -oL uniq \ + | grep --line-buffered action \ + | stdbuf -oL cut '-d ' -f1,3 | while read user group;do + if grep "_reset" <<<$group >/dev/null;then + printf "%s deleteallexcept .\n" "$user" + cat board + continue + elif grep "_" <<<$group >/dev/null;then +# xmessage "CUT IT OUT" + echo CUT IT OUT > /dev/stderr + continue + else + turn=$(expr \( $turn + 1 \) % 2) + #printf "# turn: %d\n" "$turn" > /dev/stderr + printf "$user deletegroup %s\n" "$group" + #printf "$user deletegroup %s\n" "$group" > /dev/stderr +#need to get the first point of the group clicked and translate the new shape by that much + translatex="$(grep "$group" board | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)" + translatey="$(grep "$group" board | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)" + cat "marker$turn" + printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )" + #printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )" >/dev/stderr + grep "$group" board | sed "s/$group/_marker2/g" #this is to make it still show the square around it. + printf "%s renamegroup _marker _marker%s%s\n" "$user" "$(date +%s)" "$RANDOM" + fi + done diff --git a/share/hackvr/examples/tictactoe/listen.sh b/share/hackvr/examples/tictactoe/listen.sh new file mode 100755 index 0000000..0318cd2 --- /dev/null +++ b/share/hackvr/examples/tictactoe/listen.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +#mabe not. might be buggier. +#cat board p1out | ncat -lp 1050 > p1in & +#cat board p2out | ncat -lp 1051 > p2in & +echo listening in port 1050 for player 1 and 1051 for player 2 + +mknod pin p +mknod p1out p +mknod p2out p + +cat board p1out | ncat -lp 1050 > pin & +cat board p2out | ncat -lp 1051 > pin & + +cat pin | ./game.sh | tee p1out p2out + +rm pin +rm p1out +rm p2out diff --git a/share/hackvr/examples/tictactoe/marker0 b/share/hackvr/examples/tictactoe/marker0 new file mode 100644 index 0000000..5bc0c5c --- /dev/null +++ b/share/hackvr/examples/tictactoe/marker0 @@ -0,0 +1,2 @@ +_marker addshape 1 2 .5 .5 2 1.5 1.5 2 +_marker addshape 1 2 1.5 .5 2 .5 1.5 2 diff --git a/share/hackvr/examples/tictactoe/marker1 b/share/hackvr/examples/tictactoe/marker1 new file mode 100644 index 0000000..e7aa5a7 --- /dev/null +++ b/share/hackvr/examples/tictactoe/marker1 @@ -0,0 +1 @@ +_marker addshape 3 4 1.5 1.5 2 .5 1.5 2 .5 .5 2 1.5 .5 2 diff --git a/share/hackvr/examples/tictactoe/run b/share/hackvr/examples/tictactoe/run new file mode 100755 index 0000000..c60fc43 --- /dev/null +++ b/share/hackvr/examples/tictactoe/run @@ -0,0 +1,6 @@ +#!/bin/bash +turn=$( expr $RANDOM % 2) +echo "go. player: $turn" +mknod p p +stdbuf -oL cat board p | hackvr | ./game.sh > p +rm p |