summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/dungen
diff options
context:
space:
mode:
Diffstat (limited to 'share/hackvr/examples/dungen')
-rw-r--r--share/hackvr/examples/dungen/dun2hackvr.c14
-rwxr-xr-xshare/hackvr/examples/dungen/dunexplore.sh38
2 files changed, 50 insertions, 2 deletions
diff --git a/share/hackvr/examples/dungen/dun2hackvr.c b/share/hackvr/examples/dungen/dun2hackvr.c
index 8324a24..b67af14 100644
--- a/share/hackvr/examples/dungen/dun2hackvr.c
+++ b/share/hackvr/examples/dungen/dun2hackvr.c
@@ -11,9 +11,12 @@ char field[256];
#define WEST_EXIT 1
int deg[]={0,180,270,90};
+int doorx[]={};
+int doory[]={};
void print_field() {
int i,d;
+ int x,y;
for(i=0;i<256;i++) {
//we need to draw the room here.
//each room will be... 16x16? sure....
@@ -23,25 +26,32 @@ void print_field() {
//we need to loop over each wall and check if it has a passage through it
if(field[i]) {
for(d=0;d<4;d++) {//loop over the 4 possible directions/walls
+ x=(i%16) * 16 - (7 * 16);
+ y=(i/16) * -16 + 16;
if((field[i] & (1<<(3-d))) > 0) {//if this has an exit in this bit...
printf("wall_%d_%d addshape 2 4 -7 0 7 -7 8 7 -2 8 7 -2 0 7\n",i,d);//we need 4 parts for the doorway
printf("wall_%d_%d addshape 2 4 2 0 7 2 8 7 7 8 7 7 0 7\n",i,d);
if(d % 2) {//only do the south and west doorjams. every door has an opposite door that matches it anyway
printf("wall_%d_%d addshape 2 4 -2 0 7 -2 8 7 -2 8 9 -2 0 9\n",i,d);
printf("wall_%d_%d addshape 2 4 2 0 9 2 8 9 2 8 7 2 0 7\n",i,d);
+ printf("door_close_%d_%d addshape 3 4 0 0 0 0 8 0 4 8 0 4 0 0\n",i,d);//door needs to be built to where its hinge is at 0,y,0, then moved into place so opening will work.
+ printf("door_close_%d_%d rotate 0 %d 0\n",i,d,deg[d]);
+ if(d == 1) printf("door_close_%d_%d move %d 0 %d\n",i,d,x+2,y-8);
+ if(d == 3) printf("door_close_%d_%d move %d 0 %d\n",i,d,x-8,y-2);
}
} else {//no door in this wall
printf("wall_%d_%d addshape 2 4 -7 0 7 -7 8 7 7 8 7 7 0 7\n",i,d);//solid wall
}
printf("wall_%d_%d rotate 0 %d 0\n",i,d,deg[d]);//rotate this wall into position
- printf("wall_%d_%d move %d 0 %d\n",i,d, (i%16) * 16 - (7 * 16),-(i/16) * 16 + (16));//and put it in the right spot ofc
+ printf("wall_%d_%d move %d 0 %d\n",i,d,x,y);//and put it in the right spot ofc
+ //the door needs to move either -2, +8
}
}
}
}
int main(int argc,char *argv[]) {
- if(read(0,field,sizeof(field)) > 0)
+ if(read(0,field,sizeof(field)) > 0) {
print_field();
return 0;
}
diff --git a/share/hackvr/examples/dungen/dunexplore.sh b/share/hackvr/examples/dungen/dunexplore.sh
new file mode 100755
index 0000000..389f477
--- /dev/null
+++ b/share/hackvr/examples/dungen/dunexplore.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+### run me with hackvr_coproc
+#the $USER triangle we add first is to give us some sort of avatar to see where the camera is.
+seed=1337
+echo $USER addshape 4 3 -1 0 -1 0 0 2 1 0 -1 ; echo $USER move 0 2 0
+./dungen $seed | ./dun2hackvr
+while read group action target;do
+ if [ $action = "action" ];then
+ if printf "%s\n" "${target}" | grep ^door_;then
+ printf "# clicked a door! %s\n" "${target}" >&2
+ if printf "%s\n" "${target}" | grep ^door_open;then
+ derp=$(printf "%s\n" "${target}" | sed 's/_open/_CLOSING/')
+ printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp} | tee /dev/stderr
+ while true;do
+ for i in $(seq 1 5 90);do
+ printf "%s rotate 0 +5 0\n" ${tmp}
+ sleep .1
+ done
+ tmp2=$(printf "%s\n" "${target}" | sed 's/_open/_close/')
+ printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2} | tee /dev/stderr
+ break
+ done | tee /dev/stderr &
+ else
+ tmp=$(printf "%s\n" "${target}" | sed 's/_close/_OPENING/')
+ printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp} | tee /dev/stderr
+ while true;do
+ for i in $(seq 1 5 90);do
+ printf "%s rotate 0 +-5 0\n" ${tmp}
+ sleep .1
+ done
+ tmp2=$(printf "%s\n" "${target}" | sed 's/_close/_open/')
+ printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2} | tee /dev/stderr
+ break
+ done | tee /dev/stderr &
+ fi
+ fi
+ fi
+done