summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/chess/board.sh
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2019-02-06 00:53:08 -0600
committerepoch <epoch@hacking.allowed.org>2019-02-06 00:53:08 -0600
commitbf16b7b8593d4013adbd03838af5a2fb3bce34ee (patch)
tree25944f4d4907a075e513f03b7e37a99f4c813752 /share/hackvr/examples/chess/board.sh
parent73c246a797fc6c1bac132b4eb242e1c90540e2d4 (diff)
downloadhackvr-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/chess/board.sh')
-rwxr-xr-xshare/hackvr/examples/chess/board.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/share/hackvr/examples/chess/board.sh b/share/hackvr/examples/chess/board.sh
new file mode 100755
index 0000000..f574065
--- /dev/null
+++ b/share/hackvr/examples/chess/board.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+width=8
+height=8
+cols="a b c d e f g h"
+
+for x in $(seq 1 $width);do
+ for y in $(seq 1 $height);do
+ color=$[((($y % 2) + ($x % 2))%2)+16]
+### board is on the wall. draw in x and y.
+# printf "%s%s addshape %s 4 %s %s 0 %s %s 0 %s %s 0 %s %s 0\n" $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color $x $y $[x+1] $y $[x+1] $[y+1] $x $[y+1]
+### board is on floor. draw in x and z.
+ printf "%s%s addshape %s 4 %s 0 %s %s 0 %s %s 0 %s %s 0 %s\n" $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color $x $y $[x+1] $y $[x+1] $[y+1] $x $[y+1]
+ done
+done
+
+row8="rook knight bishop queen king bishop knight rook"
+row1="$row8"
+
+color="19 19 0 0 0 0 20 20"
+
+#draw pawns. triangles.
+for x in $(seq $width);do
+ for y in 2 7;do
+ locat="$(printf "%s\n" "$cols" | cut '-d ' "-f$x")$y"
+ cat "./pieces/pawn" | sed 's/^[^ ][^ ]* addshape [0-9][0-9]* /piece_'"${locat}"' addshape '"$(printf "%s\n" "$color" | cut '-d ' "-f$y")"' /g'
+### board is on wall. use x and y.
+# printf "piece_%s move %s %s 0\n" "$locat" "$x" "$y"
+### board is on floor. use x and z.
+ printf "piece_%s move %s 0 %s\n" "$locat" "$x" "$y"
+ done
+ for y in 1 8;do
+ locat="$(printf "%s\n" "$cols" | cut '-d ' "-f$x")$y"
+ cat "./pieces/$(printf "%s\n" "$row1" | cut '-d ' "-f$x")" | sed 's/^[^ ][^ ]* addshape [0-9][0-9]* /piece_'"${locat}"' addshape '"$(printf "%s\n" "$color" | cut '-d ' "-f$y")"' /g'
+### board is on wall. use x and y.
+# printf "piece_%s move %s %s 0\n" "$locat" "$x" "$y"
+### board is on floor. use x and z.
+ printf "piece_%s move %s 0 %s\n" "$locat" "$x" "$y"
+ done
+done