]> code.delx.au - gnu-emacs/blobdiff - lisp/play/tetris.el
Update copyright year to 2016
[gnu-emacs] / lisp / play / tetris.el
index 9cc33304589e0ee88fdbef33f98e81bd54094ef0..b68b54174794b3f11ab3cd08dba19a28b043b238 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tetris.el --- implementation of Tetris for Emacs
 
-;; Copyright (C) 1997, 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <glynn@sensei.co.uk>
 ;; Version: 2.01
@@ -77,20 +77,13 @@ If the return value is a number, it is used as the timer period."
   ["blue" "white" "yellow" "magenta" "cyan" "green" "red"]
   "Vector of colors of the various shapes in text mode."
   :group 'tetris
-  :type (let ((names `("Shape 1" "Shape 2" "Shape 3"
-                      "Shape 4" "Shape 5" "Shape 6" "Shape 7"))
-             (result nil))
-         (while names
-           (add-to-list 'result
-                        (cons 'choice
-                              (cons :tag
-                                    (cons (car names)
-                                          (mapcar (lambda (color)
-                                                    (list 'const color))
-                                                  (defined-colors)))))
-                        t)
-           (setq names (cdr names)))
-         result))
+  :type '(vector (color :tag "Shape 1")
+                (color :tag "Shape 2")
+                (color :tag "Shape 3")
+                (color :tag "Shape 4")
+                (color :tag "Shape 5")
+                (color :tag "Shape 6")
+                (color :tag "Shape 7")))
 
 (defcustom tetris-x-colors
   [[0 0 1] [0.7 0 1] [1 1 0] [1 0 1] [0 1 1] [0 1 0] [1 0 0]]
@@ -272,7 +265,7 @@ each one of its four blocks.")
     (define-key map [left]     'tetris-move-left)
     (define-key map [right]    'tetris-move-right)
     (define-key map [up]       'tetris-rotate-prev)
-    (define-key map [down]     'tetris-rotate-next)
+    (define-key map [down]     'tetris-move-down)
     map))
 
 (defvar tetris-null-map
@@ -531,6 +524,16 @@ Drops the shape one square, testing for collision."
        (setq tetris-pos-x (1- tetris-pos-x)))
     (tetris-draw-shape)))
 
+(defun tetris-move-down ()
+  "Move the shape one square to the bottom."
+  (interactive)
+  (unless tetris-paused
+    (tetris-erase-shape)
+    (setq tetris-pos-y (1+ tetris-pos-y))
+    (if (tetris-test-shape)
+       (setq tetris-pos-y (1- tetris-pos-y)))
+    (tetris-draw-shape)))
+
 (defun tetris-rotate-prev ()
   "Rotate the shape clockwise."
   (interactive)