Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Tetris



Wayne Davison wrote:
>	setopt localoptions unset

Ah, I thought I'd written it for zsh native mode, but there I actually
wrote it for my interactive setup.  Here's the proper fix.

--- tetris.zsh	Mon Sep  3 01:45:35 2001
+++ tetris.zsh	Mon Sep  3 10:46:46 2001
@@ -23,6 +23,7 @@
 
 zle -N tetris
 function tetris {
+	emulate -L zsh
 	tetris_save_buffer=$BUFFER
 	tetris_save_cursor=$CURSOR
 	local i
@@ -44,6 +45,7 @@
 }
 
 function tetris-new-block {
+	emulate -L zsh
 	tetris_block=$tetris_shapes[1+RANDOM%$#tetris_shapes]
 	tetris_block_y=0
 	tetris_block_x=4
@@ -59,6 +61,7 @@
 
 zle -N tetris-left
 function tetris-left {
+	emulate -L zsh
 	tetris-place-block " "
 	(( tetris_block_x-- ))
 	tetris-block-fits || (( tetris_block_x++ ))
@@ -68,6 +71,7 @@
 
 zle -N tetris-right
 function tetris-right {
+	emulate -L zsh
 	tetris-place-block " "
 	(( tetris_block_x++ ))
 	tetris-block-fits || (( tetris_block_x-- ))
@@ -77,6 +81,7 @@
 
 zle -N tetris-rotate
 function tetris-rotate {
+	emulate -L zsh
 	tetris-place-block " "
 	local save_block=$tetris_block
 	tetris_block=$tetris_rotations[$tetris_block]
@@ -87,6 +92,7 @@
 
 zle -N tetris-drop
 function tetris-drop {
+	emulate -L zsh
 	tetris-place-block " "
 	((tetris_block_y++))
 	while tetris-block-fits; do
@@ -98,6 +104,7 @@
 
 zle -N tetris-timeout
 function tetris-timeout {
+	emulate -L zsh
 	tetris-place-block " "
 	((tetris_block_y++))
 	if tetris-block-fits; then
@@ -110,6 +117,7 @@
 }
 
 function tetris-block-dropped {
+	emulate -L zsh
 	tetris-place-block "O"
 	local fl=${tetris_blankline// /O} i=$((tetris_block_y*tetris_hsz)) y
 	for ((y=0; y!=4; y++)); do
@@ -124,6 +132,7 @@
 }
 
 function tetris-block-fits {
+	emulate -L zsh
 	local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000
 	for ((y=0; y!=4; y++)); do
 		for ((x=0; x!=4; x++)); do
@@ -143,6 +152,7 @@
 }
 
 function tetris-place-block {
+	emulate -L zsh
 	local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000
 	for ((y=0; y!=4; y++)); do
 		for ((x=0; x!=4; x++)); do
@@ -155,6 +165,7 @@
 }
 
 function tetris-render-screen {
+	emulate -L zsh
 	local s i extras
 	extras=(
 		"Score: $tetris_score"
@@ -164,7 +175,7 @@
 	)
 	for ((i=0; i!=tetris_vsz; i++)); do
 		s="$s|${tetris_board[1+i*tetris_hsz,(i+1)*tetris_hsz]}|"
-		s=$s"   "$extras[1]$'\n'
+		s=$s${extras[1]+   $extras[1]}$'\n'
 		extras[1]=()
 	done
 	s="$s+${tetris_blankline// /-}+"
@@ -172,6 +183,7 @@
 }
 
 function tetris-timed-move {
+	emulate -L zsh
 	tetris-render-screen
 	LBUFFER=
 	RBUFFER=$'\n'$tetris_screen
@@ -181,6 +193,7 @@
 
 zle -N tetris-quit
 function tetris-quit {
+	emulate -L zsh
 	if [[ ! -o always_last_prompt ]]; then
 		BUFFER=
 		zle -M $tetris_screen



Messages sorted by: Reverse Date, Date, Thread, Author