summaryrefslogtreecommitdiff
path: root/test-mvmt.sh
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-10-05 19:40:03 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2019-10-05 19:40:03 -0400
commit4891aed55e569ac1f78f854be7fb9ca15970e810 (patch)
treee16f6cab4fe63bc94b0497431b533310f97b3c0f /test-mvmt.sh
parentac0e65bc5b4067aa7bcaec29d7dad4fab03516d4 (diff)
Added Tile Heightmap Collision, for real this time.
Unlike AABB, Tile Heightmap was very easy to add, which really supprised me. I also revamped AABB to not have as many if statements.
Diffstat (limited to 'test-mvmt.sh')
-rwxr-xr-xtest-mvmt.sh26
1 files changed, 16 insertions, 10 deletions
diff --git a/test-mvmt.sh b/test-mvmt.sh
index 0f5ec67..b53ed56 100755
--- a/test-mvmt.sh
+++ b/test-mvmt.sh
@@ -7,20 +7,26 @@ yvel=1
yspd=$yvel
x2=256
y2=256
-w=16
-h=16
+w1=16
+h1=16
+w2=128
+h2=128
+u=0
+d=0
+l=0
+r=0
clear
actkbd -Ps | \
while read frame key held; do
yspd=0 && xspd=0 && negx="" && negy="";
- [ "${key#*KEY_W}" != "$key" -o "${key#*KEY_S}" != "$key" ] && yspd=$yvel
- [ "${key#*KEY_A}" != "$key" -o "${key#*KEY_D}" != "$key" ] && xspd=$xvel
- [ "${key#*KEY_W}" != "$key" ] && negy="-" && y1=$(expr $y1 - $yspd)
- [ "${key#*KEY_S}" != "$key" ] && negy="" && y1=$(expr $y1 + $yspd)
- [ "${key#*KEY_A}" != "$key" ] && negx="-" && x1=$(expr $x1 - $xspd)
- [ "${key#*KEY_D}" != "$key" ] && negx="" && x1=$(expr $x1 + $xspd)
- xy=$(printf "1\n$w,$h\n$x1,$y1\n$negx$xspd,$negy$yspd\n128,128\n$x2,$y2" | ./clld | tail -n2 | tr -d ',' | head -n1)
+ [ "${key#*KEY_W}" != "$key" -o "${key#*KEY_S}" != "$key" ] && yspd=$yvel
+ [ "${key#*KEY_A}" != "$key" -o "${key#*KEY_D}" != "$key" ] && xspd=$xvel
+ [ "${key#*KEY_W}" != "$key" ] && negy="-" && y1=$(echo "$y1-$yspd" | bc)
+ [ "${key#*KEY_S}" != "$key" ] && negy="" && y1=$(echo "$y1+$yspd" | bc)
+ [ "${key#*KEY_A}" != "$key" ] && negx="-" && x1=$(echo "$x1-$xspd" | bc)
+ [ "${key#*KEY_D}" != "$key" ] && negx="" && x1=$(echo "$x1+$xspd" | bc)
+ xy=$(printf "1\n$w1,$h1\n$x1,$y1\n$negx$xspd,$negy$yspd\n$w2,$h2\n$x2,$y2" | ./clld | tail -n2 | tr -d ',' | head -n1)
x1=$(echo "$xy" | awk '{print $1}')
y1=$(echo "$xy" | awk '{print $2}')
- printf "\33[1;1H$x1 $y1 \33[2;1H$negx$xspd $negy$yspd \b\b"
+ printf "\33[1;1H$x1 $y1 \33[2;1H$negx$xspd $negy$yspd \33[3;1H \b\b"
done