unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug in emacs tetris
@ 2007-02-28  3:59 Christopher Allan Webber
  2007-02-28 17:54 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Allan Webber @ 2007-02-28  3:59 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

Hey, I found a bug in emacs tetris that takes all the fun out of
it... I assume it's been around since emacs tetris was released, but
haven't bothered to check.  I guess that would make it... ten years?

Anyway, the bug is this...

Pause the game... you can still rotate, move and drop pieces with it
paused.  How lame is that?  Anyway, I've included a patch, named
appropriately.

I've also included a second patch which does not fix any bugs, but is
related for the gamegrid library... it makes it so that when scores
are updated that point jumps to the line where your new score has been
uploaded.  This is labeled gamegrid-enhance.patch

(If you reply to this please wide-reply as I am not subscribed to
emacs-devel.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Pause to fix tetris game mechanics when paused --]
[-- Type: text/x-diff, Size: 3604 bytes --]

diff -c /home/cwebber/elisp/tetris-old.el /home/cwebber/elisp/patch-tetris.el
*** /home/cwebber/elisp/tetris-old.el	2007-02-27 17:28:45.000000000 -0600
--- /home/cwebber/elisp/patch-tetris.el	2007-02-27 17:29:12.000000000 -0600
***************
*** 512,530 ****
  (defun tetris-move-bottom ()
    "Drops the shape to the bottom of the playing area"
    (interactive)
!   (let ((hit nil))
!     (tetris-erase-shape)
!     (while (not hit)
!       (setq tetris-pos-y (1+ tetris-pos-y))
!       (setq hit (tetris-test-shape)))
!     (setq tetris-pos-y (1- tetris-pos-y))
!     (tetris-draw-shape)
!     (tetris-shape-done)))
  
  (defun tetris-move-left ()
    "Moves the shape one square to the left"
    (interactive)
!   (unless (= tetris-pos-x 0)
      (tetris-erase-shape)
      (setq tetris-pos-x (1- tetris-pos-x))
      (if (tetris-test-shape)
--- 512,532 ----
  (defun tetris-move-bottom ()
    "Drops the shape to the bottom of the playing area"
    (interactive)
!   (if (not tetris-paused)
!       (let ((hit nil))
!         (tetris-erase-shape)
!         (while (not hit)
!           (setq tetris-pos-y (1+ tetris-pos-y))
!           (setq hit (tetris-test-shape)))
!         (setq tetris-pos-y (1- tetris-pos-y))
!         (tetris-draw-shape)
!         (tetris-shape-done))))
  
  (defun tetris-move-left ()
    "Moves the shape one square to the left"
    (interactive)
!   (unless (or (= tetris-pos-x 0)
!               tetris-paused)
      (tetris-erase-shape)
      (setq tetris-pos-x (1- tetris-pos-x))
      (if (tetris-test-shape)
***************
*** 534,541 ****
  (defun tetris-move-right ()
    "Moves the shape one square to the right"
    (interactive)
!   (unless (= (+ tetris-pos-x (tetris-shape-width))
! 	     tetris-width)
      (tetris-erase-shape)
      (setq tetris-pos-x (1+ tetris-pos-x))
      (if (tetris-test-shape)
--- 536,544 ----
  (defun tetris-move-right ()
    "Moves the shape one square to the right"
    (interactive)
!   (unless (or (= (+ tetris-pos-x (tetris-shape-width))
!                  tetris-width)
!               tetris-paused)
      (tetris-erase-shape)
      (setq tetris-pos-x (1+ tetris-pos-x))
      (if (tetris-test-shape)
***************
*** 545,564 ****
  (defun tetris-rotate-prev ()
    "Rotates the shape clockwise"
    (interactive)
!   (tetris-erase-shape)
!   (setq tetris-rot (% (+ 1 tetris-rot) 4))
!   (if (tetris-test-shape)
!       (setq tetris-rot (% (+ 3 tetris-rot) 4)))
!   (tetris-draw-shape))
  
  (defun tetris-rotate-next ()
    "Rotates the shape anticlockwise"
    (interactive)
!   (tetris-erase-shape)
!   (setq tetris-rot (% (+ 3 tetris-rot) 4))
!   (if (tetris-test-shape)
!       (setq tetris-rot (% (+ 1 tetris-rot) 4)))
!   (tetris-draw-shape))
  
  (defun tetris-end-game ()
    "Terminates the current game"
--- 548,570 ----
  (defun tetris-rotate-prev ()
    "Rotates the shape clockwise"
    (interactive)
!   (if (not tetris-paused)
!       (progn (tetris-erase-shape)
!              (setq tetris-rot (% (+ 1 tetris-rot) 4))
!              (if (tetris-test-shape)
!                  (setq tetris-rot (% (+ 3 tetris-rot) 4)))
!              (tetris-draw-shape))))
  
  (defun tetris-rotate-next ()
    "Rotates the shape anticlockwise"
    (interactive)
!   (if (not tetris-paused)
!       (progn
!         (tetris-erase-shape)
!         (setq tetris-rot (% (+ 3 tetris-rot) 4))
!         (if (tetris-test-shape)
!             (setq tetris-rot (% (+ 1 tetris-rot) 4)))
!         (tetris-draw-shape))))
  
  (defun tetris-end-game ()
    "Terminates the current game"

Diff finished.  Tue Feb 27 17:29:51 2007

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Better score updating patch for gamegrid library --]
[-- Type: text/x-diff, Size: 2992 bytes --]

diff -c /home/cwebber/elisp/gamegrid.el /home/cwebber/elisp/gamegrid-new.el
*** /home/cwebber/elisp/gamegrid.el	2007-02-27 21:02:52.000000000 -0600
--- /home/cwebber/elisp/gamegrid-new.el	2007-02-27 21:04:43.000000000 -0600
***************
*** 514,520 ****
  
  (defun gamegrid-add-score-with-update-game-score-1 (file target score)
    (let ((default-directory "/")
! 	(errbuf (generate-new-buffer " *update-game-score loss*")))
      ;; This can be called from a timer, so enable local quits.
      (with-local-quit
        (apply
--- 514,530 ----
  
  (defun gamegrid-add-score-with-update-game-score-1 (file target score)
    (let ((default-directory "/")
! 	(errbuf (generate-new-buffer " *update-game-score loss*"))
!         (marker-string (concat
!                         (user-full-name)
!                         " <"
!                         (cond ((fboundp 'user-mail-address)
!                                (user-mail-address))
!                               ((boundp 'user-mail-address)
!                                user-mail-address)
!                               (t ""))
!                         ">  "
!                         (current-time-string))))
      ;; This can be called from a timer, so enable local quits.
      (with-local-quit
        (apply
***************
*** 529,556 ****
  		(file-name-directory target))
  	 file
  	 (int-to-string score)
! 	 (concat
! 	  (user-full-name)
! 	  " <"
! 	  (cond ((fboundp 'user-mail-address)
! 		 (user-mail-address))
! 		((boundp 'user-mail-address)
! 		 user-mail-address)
! 		(t ""))
! 	  ">  "
! 	  (current-time-string))))))
      (if (buffer-modified-p errbuf)
  	(progn
  	  (display-buffer errbuf)
  	  (error "Failed to update game score file"))
        (kill-buffer errbuf))
      (let ((buf (find-buffer-visiting target)))
!       (if buf
! 	  (progn
! 	    (with-current-buffer buf
! 	      (revert-buffer nil t nil))
! 	    (display-buffer buf))
! 	(find-file-read-only-other-window target)))))
  
  (defun gamegrid-add-score-insecure (file score &optional directory)
    (save-excursion
--- 539,563 ----
  		(file-name-directory target))
  	 file
  	 (int-to-string score)
!          marker-string))))
      (if (buffer-modified-p errbuf)
  	(progn
  	  (display-buffer errbuf)
  	  (error "Failed to update game score file"))
        (kill-buffer errbuf))
      (let ((buf (find-buffer-visiting target)))
!       (save-excursion
!         (if buf
!             (progn
!               (switch-to-buffer buf)
!               (revert-buffer nil t nil)
!               (display-buffer buf))
!           (find-file-read-only target))
!         (goto-char (point-min))
!         (search-forward (concat (int-to-string score)
!                                 " " (user-login-name) " "
!                                 marker-string))
!         (beginning-of-line)))))
  
  (defun gamegrid-add-score-insecure (file score &optional directory)
    (save-excursion

Diff finished.  Tue Feb 27 21:05:50 2007

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in emacs tetris
  2007-02-28  3:59 Bug in emacs tetris Christopher Allan Webber
@ 2007-02-28 17:54 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2007-02-28 17:54 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: emacs-devel

    Pause the game... you can still rotate, move and drop pieces with it
    paused.  How lame is that?  Anyway, I've included a patch, named
    appropriately.

If you cheat at solitaire, who are you cheating? ;-).

Anyway, thanks for fixing it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-28 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-28  3:59 Bug in emacs tetris Christopher Allan Webber
2007-02-28 17:54 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).