summaryrefslogtreecommitdiff
path: root/share/hackvr/examples
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-04-13 00:09:21 -0500
committerepoch <epoch@hacking.allowed.org>2020-04-13 00:09:21 -0500
commit238552fcfc3ee9fec2bda0d29a5e1da823aec1f1 (patch)
tree8dd3b4ee9fec797f5cacbe62932d469653d644a9 /share/hackvr/examples
parentdd737c645037d32bd67a6ca6f377787297921421 (diff)
parentd30c6246ef2bd08d6420278c0c94e7173fa4a925 (diff)
downloadhackvr-238552fcfc3ee9fec2bda0d29a5e1da823aec1f1.tar.gz
hackvr-238552fcfc3ee9fec2bda0d29a5e1da823aec1f1.zip
Merge branch 'master' of ssh://21.41.41.1/var/git/hackvr
Diffstat (limited to 'share/hackvr/examples')
-rw-r--r--share/hackvr/examples/tictactoe/board18
-rw-r--r--share/hackvr/examples/tictactoe/board_orig18
-rwxr-xr-xshare/hackvr/examples/tictactoe/game.sh52
-rwxr-xr-xshare/hackvr/examples/tictactoe/run2
4 files changed, 47 insertions, 43 deletions
diff --git a/share/hackvr/examples/tictactoe/board b/share/hackvr/examples/tictactoe/board
index 607ebf3..e7494fd 100644
--- a/share/hackvr/examples/tictactoe/board
+++ b/share/hackvr/examples/tictactoe/board
@@ -1,13 +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
+boardtopleft addshape 2 4 -3 13 4 -1 13 4 -1 11 4 -3 11 4
+boardtopcenter addshape 2 4 -1 13 4 1 13 4 1 11 4 -1 11 4
+boardtopright 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
+boardmiddleleft addshape 2 4 -3 11 4 -1 11 4 -1 9 4 -3 9 4
+boardmiddlecenter addshape 2 4 -1 11 4 1 11 4 1 9 4 -1 9 4
+boardmiddleright 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
+boardbottomleft addshape 2 4 -3 9 4 -1 9 4 -1 7 4 -3 7 4
+boardbottomcenter addshape 2 4 -1 9 4 1 9 4 1 7 4 -1 7 4
+boardbottomright 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
index bc97ee4..2fff3ba 100644
--- a/share/hackvr/examples/tictactoe/board_orig
+++ b/share/hackvr/examples/tictactoe/board_orig
@@ -1,14 +1,14 @@
_reset addshape 2 3 -4 -4 4 -5 -4 4 -4 -5 4
_exit 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
+boardtopleft addshape 2 4 -3 3 4 -1 3 4 -1 1 4 -3 1 4
+boardtopcenter addshape 2 4 -1 3 4 1 3 4 1 1 4 -1 1 4
+boardtopright 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
+boardmiddleleft addshape 2 4 -3 1 4 -1 1 4 -1 -1 4 -3 -1 4
+boardmiddlecenter addshape 2 4 -1 1 4 1 1 4 1 -1 4 -1 -1 4
+boardmiddleright 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
+boardbottomleft addshape 2 4 -3 -1 4 -1 -1 4 -1 -3 4 -3 -3 4
+boardbottomcenter addshape 2 4 -1 -1 4 1 -1 4 1 -3 4 -1 -3 4
+boardbottomright addshape 2 4 1 -1 4 3 -1 4 3 -3 4 1 -3 4
diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh
index b4187dd..92192cc 100755
--- a/share/hackvr/examples/tictactoe/game.sh
+++ b/share/hackvr/examples/tictactoe/game.sh
@@ -4,30 +4,34 @@ BOARDFILE=board_orig
cat camera.pos $BOARDFILE
echo "go. player: $turn" >&2
grep --line-buffered action \
- | while read user derp group;do
-# echo FUCK >&2
- if grep "_reset" <<<$group >/dev/null;then
- printf "%s deleteallexcept .\n" "$user"
- cat $BOARDFILE
- continue
- elif grep "_exit" <<<$group >/dev/null;then #this doesn't work in local games. :/
- exit 0
- 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
+ | while read user action group;do
+ if [ $action = "action" ];then
+ if grep "_reset" <<<$group >/dev/null;then
+ printf "%s deleteallexcept %s\n" "$user" "$user"
+ cat $BOARDFILE
+ continue
+ elif grep "_exit" <<<$group >/dev/null;then
+ #if a program wants to exit, it should just exit.
+ #the program may have been ran by some other program.
+ #maybe just filter out server-side quit messages for your own username?
+ #any user quit will cause any hackvr to quit?
+ #printf "%s quit\n" "$user"
+ exit 0
+ elif grep "_" <<<$group >/dev/null;then
+ echo CUT IT OUT > /dev/stderr
+ continue
+ elif grep "^board" <<<$group >/dev/null;then
+ turn=$(expr \( $turn + 1 \) % 2)
+ #printf "# turn: %d\n" "$turn" > /dev/stderr
+ printf "%s deletegroup %s\n" "$user" "$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" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)"
- translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)"
- cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0
-# 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" $BOARDFILE | 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"
+ translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)"
+ translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)"
+ cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0
+ grep "$group" $BOARDFILE | sed "s/$group/_marked/g"
+ else
+ xmessage "what? $group"
+ fi
fi
done
diff --git a/share/hackvr/examples/tictactoe/run b/share/hackvr/examples/tictactoe/run
index bf9c87a..54d712a 100755
--- a/share/hackvr/examples/tictactoe/run
+++ b/share/hackvr/examples/tictactoe/run
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
turn=$( expr $RANDOM % 2)
-echo "go. player: $turn"
+echo "# go. player: $turn" >&2
hackvr_coproc ./game.sh