From 30bfb25dceedcc0ad84b06194856edb28297ba83 Mon Sep 17 00:00:00 2001 From: epoch Date: Wed, 6 Feb 2019 04:52:59 -0600 Subject: added elevation choice and a default camera rotation for chess example --- share/hackvr/examples/chess/board.sh | 28 +++++++++++++++++------ share/hackvr/examples/chess/gnuchess-to-hackvr.sh | 5 ++-- share/hackvr/examples/chess/run | 3 ++- 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/chess/board.sh b/share/hackvr/examples/chess/board.sh index f574065..96b1b85 100755 --- a/share/hackvr/examples/chess/board.sh +++ b/share/hackvr/examples/chess/board.sh @@ -1,16 +1,29 @@ #!/bin/bash +e=$1 #elevation of board width=8 height=8 cols="a b c d e f g h" +printf "junk set camera.r.x -45\n" + 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] +# printf "%s%s addshape %s 4 %s %s %s %s %s %s %s %s %s %s %s %s\n" \ +# $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color \ +# $x $y $e \ +# $[x+1] $y $e \ +# $[x+1] $[y+1] $e \ +# $x $[y+1] $e ### 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] + printf "%s%s addshape %s 4 %s %s %s %s %s %s %s %s %s %s %s %s\n" \ + $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color \ + $x $e $y \ + $[x+1] $e $y \ + $[x+1] $e $[y+1] \ + $x $e $[y+1] done done @@ -25,16 +38,17 @@ for x in $(seq $width);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" +# printf "piece_%s move %s %s %s\n" "$locat" "$x" "$y" "$e" ### board is on floor. use x and z. - printf "piece_%s move %s 0 %s\n" "$locat" "$x" "$y" + printf "piece_%s move %s %s %s\n" "$locat" "$x" "$e" "$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' + 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" +# printf "piece_%s move %s %s %s\n" "$locat" "$x" "$y" "$e" ### board is on floor. use x and z. - printf "piece_%s move %s 0 %s\n" "$locat" "$x" "$y" + printf "piece_%s move %s %s %s\n" "$locat" "$x" "$e" "$y" done done diff --git a/share/hackvr/examples/chess/gnuchess-to-hackvr.sh b/share/hackvr/examples/chess/gnuchess-to-hackvr.sh index 0b94a87..841389b 100755 --- a/share/hackvr/examples/chess/gnuchess-to-hackvr.sh +++ b/share/hackvr/examples/chess/gnuchess-to-hackvr.sh @@ -1,4 +1,5 @@ #!/bin/sh +e=$1 tee /dev/stderr | while read first second third;do if [ "_$first" = "_feature" ];then printf "# just gnuchess saying what features it has: %s %s %s\n" "$first" "$second" "$third" >&2 @@ -17,9 +18,9 @@ tee /dev/stderr | while read first second third;do y=$(printf "%s\n" "$to" | fold -w1 | tail -n1) magic=$(printf "%s\n" "$move" | fold -w1 | tail -n+5 | tr -d '\n') ### if the board is on the wall we need to use x and y -# printf "piece_%s move %s %s 0\n" "$from" "$x" "$y" | tee /dev/stderr +# printf "piece_%s move %s %s %s\n" "$from" "$x" "$y" "$e" | tee /dev/stderr ### the board is on the floor atm. use x and z - printf "piece_%s move %s 0 %s\n" "$from" "$x" "$y" | tee /dev/stderr + printf "piece_%s move %s %s %s\n" "$from" "$x" "$e" "$y" | tee /dev/stderr printf "#delete the old piece_%s group\n" printf "epoch deletegroup piece_%s\n" "$to" diff --git a/share/hackvr/examples/chess/run b/share/hackvr/examples/chess/run index 4f0cdce..5a0941b 100755 --- a/share/hackvr/examples/chess/run +++ b/share/hackvr/examples/chess/run @@ -1,4 +1,5 @@ #!/bin/bash +export elevation=0 mknod p p -stdbuf -oL cat camera.pos <(./board.sh) <(cat p | ./gnuchess-to-hackvr.sh) | hackvr "$USER" | ./hackvr-to-gnuchess.sh | gnuchess -x > p +stdbuf -oL cat camera.pos <(./board.sh $elevation) <(cat p | ./gnuchess-to-hackvr.sh $elevation) | hackvr "$USER" | ./hackvr-to-gnuchess.sh | gnuchess -x > p rm p -- cgit v1.2.3 From 978e097ebfb50d70e5e45530cdf0fecc7654c641 Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 7 Feb 2019 03:06:49 -0600 Subject: tictactoe changes likely to get overwritten --- share/hackvr/examples/tictactoe/game.sh | 2 +- share/hackvr/examples/tictactoe/listen.sh | 4 ++-- share/hackvr/examples/tictactoe/run | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh index 8c741fc..0ad81f9 100755 --- a/share/hackvr/examples/tictactoe/game.sh +++ b/share/hackvr/examples/tictactoe/game.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash turn=$( expr $RANDOM % 2) -cat camera.pos +cat camera.pos board echo "go. player: $turn" >&2 stdbuf -oL uniq \ | grep --line-buffered action \ diff --git a/share/hackvr/examples/tictactoe/listen.sh b/share/hackvr/examples/tictactoe/listen.sh index 0318cd2..b98fe37 100755 --- a/share/hackvr/examples/tictactoe/listen.sh +++ b/share/hackvr/examples/tictactoe/listen.sh @@ -9,8 +9,8 @@ mknod pin p mknod p1out p mknod p2out p -cat board p1out | ncat -lp 1050 > pin & -cat board p2out | ncat -lp 1051 > pin & +cat p1out | ncat -lp 1050 > pin & +cat p2out | ncat -lp 1051 > pin & cat pin | ./game.sh | tee p1out p2out diff --git a/share/hackvr/examples/tictactoe/run b/share/hackvr/examples/tictactoe/run index 0f14b8f..4d49770 100755 --- a/share/hackvr/examples/tictactoe/run +++ b/share/hackvr/examples/tictactoe/run @@ -2,5 +2,5 @@ turn=$( expr $RANDOM % 2) echo "go. player: $turn" mknod p p -stdbuf -oL cat board p | hackvr | ./game.sh > p +stdbuf -oL p | hackvr | ./game.sh > p rm p -- cgit v1.2.3